rs_toolsbox/tests/spiral_cryption.rs

27 lines
948 B
Rust

#[cfg(test)]
mod spriral_test {
#[test]
fn encrypt_and_decrypt() {
let origin_text = "Hello, world!".to_string();
let encrypted_text = rs_toolbox::encryption::spiral::encrypt(origin_text.clone());
println!("encrypted_text: {}", encrypted_text);
let decrypted_text =
rs_toolbox::encryption::spiral::decrypt(encrypted_text).expect("decrypt failed");
assert_eq!(origin_text, decrypted_text);
}
#[test]
fn decrypt_foreign() {
let encrypted = "[13WOHv6CLGoIcqX5se6WvHM3pGNBH7wVJONahG7k0Q==".to_string();
let decrypted_text = match rs_toolbox::encryption::spiral::decrypt(encrypted) {
Ok(text) => text,
Err(e) => {
println!("error: {}", e);
panic!("decrypt failed");
}
};
println!("decrypted_text: {}", decrypted_text);
assert_eq!("cxfh@83864830", decrypted_text);
}
}