From: www-data Date: Thu, 8 Aug 2019 08:34:55 +0000 (+0200) Subject: Cleaning X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=c1a5fe1d8e733d744a94acf278903133e2a72115;p=rup.git Cleaning --- diff --git a/src/crypto.rs b/src/crypto.rs index f415fa1..a7aa5b9 100644 --- a/src/crypto.rs +++ b/src/crypto.rs @@ -43,10 +43,8 @@ pub fn encrypt(key: &str, plain_text: &str) -> Result { let iv = rand::thread_rng().gen::<[u8; 16]>(); let cipher_text = - match symm::encrypt(symm::Cipher::aes_128_cbc(), &key_as_bytes, Some(&iv), text_as_bytes) { - Ok(t) => t, - Err(_e) => return Err(EncryptError::UnableToEncrypt) - }; + symm::encrypt(symm::Cipher::aes_128_cbc(), &key_as_bytes, Some(&iv), text_as_bytes) + .map_err(|_e| EncryptError::UnableToEncrypt)?; let hash_text = sha256(&text_as_bytes); diff --git a/src/main.rs b/src/main.rs index 6c9ab27..f1e66ee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,10 +53,10 @@ struct Config { 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)