1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-23 13:17:44 +00:00

Add test for blowfish module

This commit is contained in:
Joshua Goins 2023-08-02 16:26:20 -04:00
parent b180cf5aac
commit e286b93dfc

View file

@ -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");
}
}