diff --git a/src/blowfish.rs b/src/blowfish.rs index c1f2bcd..ae3d278 100755 --- a/src/blowfish.rs +++ b/src/blowfish.rs @@ -145,3 +145,18 @@ impl Blowfish { (r ^ self.p[0], l ^ self.p[1]) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_encrypt() { + let blowfish = Blowfish::new(b"test_case"); + + let expected_encrypted = [63, 149, 97, 229, 5, 35, 46, 128, 194, 107, 69, 132, 85, 202, 2, 126]; + + assert_eq!(blowfish.encrypt(b"hello, world!").unwrap(), expected_encrypted); + assert_eq!(String::from_utf8(blowfish.decrypt(&expected_encrypted).unwrap()).unwrap(), "hello, world!\0\0\0"); + } +}