df1t_cyph/
lib.rs

1pub mod maps {
2    pub mod chars;
3    pub mod salt;
4}
5mod shared {
6    pub mod parse;
7}
8mod encpt {
9    pub mod decrypt;
10    pub mod encrypt;
11    pub mod analyse {
12        pub mod read;
13    }
14    pub mod math {
15        pub mod matrix;
16        pub mod process;
17    }
18    pub mod mapping {
19        pub mod mapper;
20        pub mod switcher;
21    }
22}
23pub use encpt::decrypt::df1t_decrypt;
24pub use encpt::encrypt::df1t_encrypt;
25
26#[cfg(test)]
27mod tests {
28    use super::*;
29
30    #[test]
31    fn encp_and_decp1() {
32        let salt = "qsf876sqdf";
33        let buffer = "password";
34        let enc = df1t_encrypt(buffer.to_owned(), salt.clone().to_string());
35        let res = df1t_decrypt(enc.unwrap().to_owned(), salt.to_owned());
36        assert_eq!(res.unwrap().to_owned(), buffer);
37    }
38    #[test]
39    fn encp_and_decp2() {
40        let salt = "76sqdf";
41        let buffer = "pa89631ord";
42        let enc = df1t_encrypt(buffer.to_owned(), salt.clone().to_string());
43        println!("{:?}", &enc);
44        let res = df1t_decrypt(enc.unwrap().to_owned(), salt.to_owned());
45        assert_eq!(res.unwrap().to_owned(), buffer);
46    }
47    #[test]
48    fn encp_and_decp3() {
49        let salt = "76sqdf";
50        let buffer = "76sqdf";
51        let enc = df1t_encrypt(buffer.to_owned(), salt.clone().to_string());
52        let res = df1t_decrypt(enc.unwrap().to_owned(), salt.to_owned());
53        assert_eq!(res.unwrap().to_owned(), buffer);
54    }
55    #[test]
56    fn encp_and_decp4() {
57        let salt = "afdchjsrh9841d";
58        let buffer = "maqzhf49qsd8ds4fgqsd94f89gs4hqsd68dsqh9yk44qds3";
59        let enc = df1t_encrypt(buffer.to_owned(), salt.clone().to_string());
60        let res = df1t_decrypt(enc.unwrap().to_owned(), salt.to_owned());
61        assert_eq!(res.unwrap().to_owned(), buffer);
62    }
63
64    #[test]
65    #[should_panic]
66    fn encp_and_decp5() {
67        let salt = "afdchjsrh98fqsd8489qsdfq6sf441d";
68        let buffer = "maqzhf49qsd8ds4fgqsd94f89gs4hqsd68dsqh9yk44qds3";
69        let enc = df1t_encrypt(buffer.to_owned(), salt.clone().to_string());
70        let _ = df1t_decrypt(enc.unwrap().to_owned(), salt.to_owned());
71    }
72    #[test]
73    #[should_panic]
74    fn encp_and_decp6() {
75        let salt = "";
76        let buffer = "maqzhf49qsd8ds4fgqsd94f89gs4hqsd68dsqh9yk44qds3";
77        let enc = df1t_encrypt(buffer.to_owned(), salt.clone().to_string());
78        let _ = df1t_decrypt(enc.unwrap().to_owned(), salt.to_owned());
79    }
80    #[test]
81    #[should_panic]
82    fn encp_and_decp7() {
83        let salt = "sdfqsdf";
84        let buffer = "";
85        let enc = df1t_encrypt(buffer.to_owned(), salt.clone().to_string());
86        let _ = df1t_decrypt(enc.unwrap().to_owned(), salt.to_owned());
87    }
88    #[test]
89    fn encp_and_decp8() {
90        let salt = "8";
91        let buffer = "8";
92        let enc = df1t_encrypt(buffer.to_owned(), salt.clone().to_string());
93        let _ = df1t_decrypt(enc.unwrap().to_owned(), salt.to_owned());
94    }
95}
96// fn main() {
97//     // Example usage
98//     let salt = "0hfdf";
99//     let password = "1sd41";
100//     let res = df1t_encrypt(password.to_owned(), salt.clone().to_string());
101
102//     let res1 = df1t_decrypt(res.unwrap().to_owned(), salt.to_owned());
103//     println!("{}", res1.unwrap())
104// }
105
106//[[652, 165, 314, 671, 113],
107// [422, 103, 923, 314, 194],
108// [113, 389, 314, 422, 652],
109// [923, 113, 194, 103, 422],
110// [652, 389, 000, 000, 000]]