feat: fix clippy

This commit is contained in:
2023-10-14 00:05:11 +08:00
parent 69529b1813
commit 09bb894242
15 changed files with 68 additions and 66 deletions

View File

@@ -10,16 +10,16 @@ use crate::util::{base64_decode, base64_encode};
#[derive(Debug, Clone, Copy)]
enum EncryptAlgo {
RSA,
ECDH,
Rsa,
Ecdh,
}
impl EncryptAlgo {
fn from_str(algo: &str) -> XResult<Self> {
match algo {
"rsa" => Ok(Self::RSA),
"x25519" | "ecdh" => Ok(Self::ECDH),
_ => return simple_error!("Unknown algo: {}", algo),
"rsa" => Ok(Self::Rsa),
"x25519" | "ecdh" => Ok(Self::Ecdh),
_ => simple_error!("Unknown algo: {}", algo),
}
}
}
@@ -68,8 +68,8 @@ impl Command for CommandImpl {
success!("User pin verify success!");
let text = match algo {
EncryptAlgo::RSA => trans.decipher(Cryptogram::RSA(&cipher_bytes))?,
EncryptAlgo::ECDH => trans.decipher(Cryptogram::ECDH(&cipher_bytes))?,
EncryptAlgo::Rsa => trans.decipher(Cryptogram::RSA(&cipher_bytes))?,
EncryptAlgo::Ecdh => trans.decipher(Cryptogram::ECDH(&cipher_bytes))?,
};
success!("Clear text HEX: {}", hex::encode(&text));
success!("Clear text base64: {}", base64_encode(&text));