let iv = rand::thread_rng().gen::<[u8; 16]>();\r
\r
let cipher_text =\r
- match symm::encrypt(symm::Cipher::aes_128_cbc(), &key_as_bytes, Some(&iv), text_as_bytes) {\r
- Ok(t) => t,\r
- Err(_e) => return Err(EncryptError::UnableToEncrypt)\r
- };\r
+ symm::encrypt(symm::Cipher::aes_128_cbc(), &key_as_bytes, Some(&iv), text_as_bytes)\r
+ .map_err(|_e| EncryptError::UnableToEncrypt)?;\r
\r
let hash_text = sha256(&text_as_bytes);\r
\r
fn get_exe_name() -> String {
let first_arg = std::env::args().nth(0).unwrap();
- //dbg!(&first_arg);
let sep: &[_] = &['\\', '/'];
first_arg[first_arg.rfind(sep).unwrap()+1..].to_string()
}
+
fn read_key() -> String {
let mut key = String::new();
File::open(consts::FILE_KEY)