feat: comments

This commit is contained in:
2023-10-29 00:43:27 +08:00
parent 9e46d11e89
commit 25de8ea682

View File

@@ -14,16 +14,16 @@ use crate::util_progress::Progress;
#[derive(Debug, Args)]
pub struct CmdDirectDecrypt {
/// Files in
/// File input
#[arg(long, short = 'i')]
pub file_in: PathBuf,
/// Files output
/// File output
#[arg(long, short = 'o')]
pub file_out: PathBuf,
/// Remove source file
#[arg(long, short = 'R')]
pub remove_file: bool,
/// Key in HEX
/// Key in HEX (32 bytes)
#[arg(long, short = 'k')]
pub key: String,
}
@@ -36,10 +36,12 @@ impl Drop for CmdDirectDecrypt {
const DIRECT_ENCRYPT_MAGIC: &str = "e2c50001";
// Format
// [4 bytes] - magic 0xe2c50001
// Direct decrypt file format:
// [4 bytes] - magic 0xe2 0xc5 0x00 0x01
// [32 bytes] - key digest
// [12 bytes] - nonce
// [n bytes] - ciphertext
// [16 bytes] - tag
pub fn direct_decrypt(cmd_direct_decrypt: CmdDirectDecrypt) -> XResult<()> {
let key = opt_result!(hex::decode(&cmd_direct_decrypt.key), "Parse key failed: {}");
if key.len() != 32 {