1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

#[derive(Debug)] 
pub struct HideConfig<'a> {
    pub payload_path: &'a str,
    pub carrier_path: &'a str,
    pub output_path: Option<&'a str>,
    pub strategy: Option<&'a str>,
}

#[derive(Debug)] 
pub struct RevealConfig<'a> {
    pub carrier_path: &'a str,
    pub output_path: Option<&'a str>,
    pub strategy: Option<&'a str>,
}

mod text;
mod images;
mod videos;

pub fn run_hide (config: HideConfig) {
    if config.payload_path.ends_with(".png") && config.carrier_path.ends_with(".png") {
        println!("Hide using - Least Significant Bit PNG Steganography (lsb_png_steganography)");

        if let Some(output_path) = config.output_path {
            images::lsb_png_steganography::hide(config.payload_path, config.carrier_path, output_path);
        } else {
            images::lsb_png_steganography::hide(config.payload_path, config.carrier_path, "./steg_hide_output.png");
        }
    } else if config.payload_path.ends_with(".txt") && config.carrier_path.ends_with(".txt") {
        println!("Hide using - whitespace text steganography");

        if let Some(output_path) = config.output_path {
            text::whitespace_text_steganography::hide(config.payload_path, config.carrier_path, output_path);
        } else {
            text::whitespace_text_steganography::hide(config.payload_path, config.carrier_path, "./steg_hide_output.txt");
        }
    }
}

pub fn run_reveal (config: RevealConfig) {
    if config.carrier_path.ends_with(".png") {
        if let Some(output_path) = config.output_path {
            images::lsb_png_steganography::reveal(config.carrier_path, output_path);
        } else {
            images::lsb_png_steganography::reveal(config.carrier_path, "./steg_reveal_output.png");
        }
    } else if config.carrier_path.ends_with(".txt") {
        if let Some(output_path) = config.output_path {
            text::whitespace_text_steganography::reveal(config.carrier_path, output_path);
        } else {
            text::whitespace_text_steganography::reveal(config.carrier_path, "./steg_hide_output.txt");
        }
    }
}

#[cfg(test)]
mod tests {
    use super::{ HideConfig, RevealConfig };

    #[test]
    fn lsb_png_steganography_hide_does_not_panic() {
        let config = HideConfig {
            strategy: None,
            payload_path: "./images/payload.png",
            carrier_path: "./images/carrier.png",
            output_path: Some("images/output/lsb_png_steganography_hide_does_not_panic.png"),
        };

        super::run_hide(config);
    }

     #[test]
    fn lsb_png_steganography_reveal_does_not_panic() {
        let config = RevealConfig {
            strategy: None,
            carrier_path: "./images/hidden.png",
            output_path: Some("./images/output/whitespace_text_steganography_reveal_does_not_panic.png"),
        };

        super::run_reveal(config);
    }

    #[test]
    fn whitespace_text_steganography_hide_does_not_panic() {
        let config = HideConfig {
            strategy: None,
            payload_path: "./texts/payload_haiku.txt",
            carrier_path: "./texts/carrier_sonnet.txt",
            output_path: Some("./texts/output/whitespace_text_steganography_hide_does_not_panic.txt"),
        };

        super::run_hide(config);
    }

    #[test]
    fn whitespace_text_steganography_reveal_does_not_panic() {
        let config = RevealConfig {
            strategy: None,
            carrier_path: "./texts/hidden.txt", 
            output_path: Some("./texts/output/whitespace_text_steganography_reveal_does_not_panic.txt"),
        };

        super::run_reveal(config);
    }
}