feat: update encrypt
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use rand::random;
|
use rand::random;
|
||||||
use rust_util::{debugging, failure, simple_error, success, XResult};
|
use rust_util::{debugging, failure, opt_result, simple_error, success, XResult};
|
||||||
|
|
||||||
use crate::config::{TinyEncryptConfig, TinyEncryptConfigEnvelop};
|
use crate::config::{TinyEncryptConfig, TinyEncryptConfigEnvelop};
|
||||||
use crate::spec::{TinyEncryptEnvelop, TinyEncryptEnvelopType};
|
use crate::spec::{EncMetadata, TinyEncryptEnvelop, TinyEncryptEnvelopType, TinyEncryptMeta};
|
||||||
use crate::util::TINY_ENC_CONFIG_FILE;
|
use crate::util::TINY_ENC_CONFIG_FILE;
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
@@ -39,7 +40,17 @@ fn encrypt_single(path: &PathBuf, envelops: &[&TinyEncryptConfigEnvelop]) -> XRe
|
|||||||
let (key, nonce) = make_key256_and_nonce();
|
let (key, nonce) = make_key256_and_nonce();
|
||||||
let envelops = encrypt_envelops(&key, &envelops)?;
|
let envelops = encrypt_envelops(&key, &envelops)?;
|
||||||
|
|
||||||
debugging!("Envelops: {:?}", envelops);
|
let file_metadata = opt_result!(fs::metadata(path), "Read file: {} meta failed: {}", path.display());
|
||||||
|
let enc_metadata = EncMetadata {
|
||||||
|
comment: None,
|
||||||
|
encrypted_comment: None,
|
||||||
|
encrypted_meta: None,
|
||||||
|
compress: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
let _encrypt_meta = TinyEncryptMeta::new(&file_metadata, &enc_metadata, &nonce, envelops);
|
||||||
|
|
||||||
|
// TODO write to file and do encrypt
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user