diff --git a/Cargo.lock b/Cargo.lock index ce05aeb..3be734b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2128,7 +2128,7 @@ dependencies = [ [[package]] name = "tiny-encrypt" -version = "0.2.4" +version = "0.2.5" dependencies = [ "aes-gcm-stream", "base64", diff --git a/Cargo.toml b/Cargo.toml index 85cfa4c..fa6ede3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tiny-encrypt" -version = "0.2.4" +version = "0.2.5" edition = "2021" license = "MIT" description = "A simple and tiny file encrypt tool" diff --git a/src/cmd_decrypt.rs b/src/cmd_decrypt.rs index 173be13..47d4331 100644 --- a/src/cmd_decrypt.rs +++ b/src/cmd_decrypt.rs @@ -105,6 +105,19 @@ pub fn decrypt_single(config: &Option, debugging!("Decrypt key: {}", hex::encode(&key)); debugging!("Decrypt nonce: {}", hex::encode(&nonce)); + if let Some(encrypted_comment) = &meta.encrypted_comment { + match util::decode_base64(encrypted_comment) { + Err(e) => warning!("Decode encrypted comment failed: {}", e), + Ok(encrypted_comment_based_bytes) => match aes_gcm_decrypt(&key, &nonce, &encrypted_comment_based_bytes) { + Err(e) => warning!("Decode encrypted comment failed: {}", e), + Ok(decrypted_comment_bytes) => match String::from_utf8(decrypted_comment_bytes.clone()) { + Err(_) => success!("Encrypted message hex: {}", hex::encode(&decrypted_comment_bytes)), + Ok(message) => success!("Encrypted message: {}", message), + } + } + } + } + let mut file_out = File::create(path_out)?; let start = Instant::now(); diff --git a/src/cmd_info.rs b/src/cmd_info.rs index a3fe46a..de8e306 100644 --- a/src/cmd_info.rs +++ b/src/cmd_info.rs @@ -27,6 +27,7 @@ pub fn info(cmd_info: CmdInfo) -> XResult<()> { warning!("Parse Tiny Encrypt file info failed: {}", e); } } + println!(); Ok(()) } @@ -95,7 +96,7 @@ pub fn info_single(path: &PathBuf, cmd_info: &CmdInfo) -> XResult<()> { }; infos.push(format!("{}: {}", header("Encryption algorithm"), encryption_algorithm)); - success!("{}\n", infos.join("\n")); + success!("{}", infos.join("\n")); Ok(()) }