26 lines
782 B
Rust
26 lines
782 B
Rust
#[cfg(test)]
|
|
mod aes_test {
|
|
#[test]
|
|
fn encrypt_zero_padding() {
|
|
let cipher_data =
|
|
rs_toolbox::encryption::aes::encrypt_zero_padding("123456", "Hello world.");
|
|
let cipher_hex = rs_toolbox::serialize::to_hex(cipher_data);
|
|
assert_eq!(cipher_hex, "722e10838a6c770d631701ee7c37c334");
|
|
}
|
|
|
|
#[test]
|
|
fn decrypt_zero_padding() {
|
|
let plain_data = rs_toolbox::encryption::aes::decrypt_zero_padding(
|
|
"123456",
|
|
rs_toolbox::serialize::from_hex("722e10838a6c770d631701ee7c37c334").unwrap(),
|
|
);
|
|
if plain_data.is_err() {
|
|
panic!("Decrypt failed");
|
|
}
|
|
assert_eq!(
|
|
String::from_utf8(plain_data.unwrap()).unwrap(),
|
|
"Hello world."
|
|
);
|
|
}
|
|
}
|