feat: v0.2.5, show decrytped encrypted-message

This commit is contained in:
2023-10-11 01:09:20 +08:00
parent c35fef7bf1
commit 6d1d6ab085
4 changed files with 17 additions and 3 deletions

View File

@@ -105,6 +105,19 @@ pub fn decrypt_single(config: &Option<TinyEncryptConfig>,
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();