feat: v1.12.7
This commit is contained in:
@@ -2,7 +2,7 @@ use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
use rust_util::util_clap::{Command, CommandError};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::{cmdutil, hmacutil, util};
|
||||
use crate::{cmdutil, hmacutil, pbeutil, util};
|
||||
|
||||
pub struct CommandImpl;
|
||||
|
||||
@@ -21,14 +21,22 @@ impl Command for CommandImpl {
|
||||
.required(true)
|
||||
.help("Plaintext"),
|
||||
)
|
||||
.arg(Arg::with_name("with-pbe").long("with-pbe").help("With PBE encryption"))
|
||||
.arg(Arg::with_name("pbe-iteration").long("pbe-iteration").takes_value(true).help("PBE iteration, default 100000"))
|
||||
.arg(cmdutil::build_json_arg())
|
||||
}
|
||||
|
||||
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
||||
let json_output = cmdutil::check_json_output(sub_arg_matches);
|
||||
|
||||
let plaintext = sub_arg_matches.value_of("plaintext").unwrap();
|
||||
let hmac_encrypt_ciphertext = hmacutil::hmac_encrypt_from_string(plaintext)?;
|
||||
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 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)?;
|
||||
}
|
||||
let hmac_encrypt_ciphertext = hmacutil::hmac_encrypt_from_string(&text)?;
|
||||
|
||||
if json_output {
|
||||
let mut json = BTreeMap::<&'_ str, String>::new();
|
||||
|
||||
Reference in New Issue
Block a user