feat: pbe encryption
This commit is contained in:
@@ -22,6 +22,7 @@ impl Command for CommandImpl {
|
||||
.help("Plaintext"),
|
||||
)
|
||||
.arg(Arg::with_name("with-pbe").long("with-pbe").help("With PBE encryption"))
|
||||
.arg(Arg::with_name("double-pin-check").long("double-pin-check").help("Double PIN check"))
|
||||
.arg(Arg::with_name("pbe-iteration").long("pbe-iteration").takes_value(true).help("PBE iteration, default 100000"))
|
||||
.arg(cmdutil::build_json_arg())
|
||||
}
|
||||
@@ -32,9 +33,10 @@ impl Command for CommandImpl {
|
||||
let mut text = sub_arg_matches.value_of("plaintext").unwrap().to_string();
|
||||
let with_pbe = sub_arg_matches.is_present("with-pbe");
|
||||
if with_pbe {
|
||||
let double_pin_check = sub_arg_matches.is_present("double-pin-check");
|
||||
let iteration = sub_arg_matches.value_of("pbe-iteration")
|
||||
.map(|x| x.parse::<u32>().unwrap()).unwrap_or(100000);
|
||||
text = pbeutil::simple_pbe_encrypt_with_prompt_from_string(iteration, &text)?;
|
||||
text = pbeutil::simple_pbe_encrypt_with_prompt_from_string(iteration, &text, double_pin_check)?;
|
||||
}
|
||||
let hmac_encrypt_ciphertext = hmacutil::hmac_encrypt_from_string(&text)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user