feat(crypto):增加螺旋自解密加密算法支持函数。
This commit is contained in:
26
tests/spiral_cryption.rs
Normal file
26
tests/spiral_cryption.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
#[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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user