false-bottom/examples/encryption.rs

24 lines
729 B
Rust

use false_bottom::FBCrypt;
fn main() {
let real_msg = "The troops are headed due north";
let fake_msg = "The troops are headed due south";
let mut fb = FBCrypt::init(12, 12).unwrap();
let real_key = fb.add(&real_msg.as_bytes()).unwrap();
let fake_key = fb.add(&fake_msg.as_bytes()).unwrap();
let real_decr = fb.decrypt(&real_key).unwrap();
let fake_decr = fb.decrypt(&fake_key).unwrap();
let real_str = String::from_utf8(real_decr).unwrap();
let fake_str = String::from_utf8(fake_decr).unwrap();
let cipher = fb.export();
println!("Cipher: {cipher}");
println!("Decrypted Contents:");
println!("Real: {real_str}\nFake: {fake_str}");
assert_eq!(real_msg, real_str);
}