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:
parent
b180cf5aac
commit
e286b93dfc
1 changed files with 15 additions and 0 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue