25 lines
745 B
Rust
25 lines
745 B
Rust
use false_bottom::{FalseBottom, Fb128};
|
|
|
|
fn main() {
|
|
// Input messages
|
|
let fake_msg = "Weather department warns of heavy rains within the upcoming two days";
|
|
let real_msg = "I have gathered intel regarding the government's illegal spying";
|
|
|
|
// Cipher initialization
|
|
let mut fb = Fb128::init(10, 10);
|
|
|
|
// Encryption (Adding messages is not limited to 2)
|
|
let fake_key = fb.add(&fake_msg.as_bytes());
|
|
let real_key = fb.add(&real_msg.as_bytes());
|
|
|
|
// Decryption
|
|
let fake_decr = fb.decrypt(&fake_key).unwrap();
|
|
let real_decr = fb.decrypt(&real_key).unwrap();
|
|
|
|
let fake_str = String::from_utf8(fake_decr).unwrap();
|
|
let real_str = String::from_utf8(real_decr).unwrap();
|
|
|
|
assert_eq!(fake_msg, fake_str);
|
|
assert_eq!(real_msg, real_str);
|
|
}
|