[kwm] fix: Bodian build issue

This commit is contained in:
鲁树人 2024-09-15 16:34:10 +01:00
parent a6e1c54902
commit 1e1d642149
2 changed files with 3 additions and 3 deletions

View File

@ -7,7 +7,7 @@ use core::{KuwoDes, Mode};
use umc_utils::base64; use umc_utils::base64;
/// Decrypt string content /// Decrypt string content
pub fn decrypt_ksing(data: &str, key: &[u8; 8]) -> Result<String> { pub fn decrypt_ksing<T: AsRef<[u8]>>(data: T, key: &[u8; 8]) -> Result<String> {
let mut decoded = base64::decode(data)?; let mut decoded = base64::decode(data)?;
let des = KuwoDes::new(key, Mode::Decrypt); let des = KuwoDes::new(key, Mode::Decrypt);
@ -30,7 +30,7 @@ pub fn encrypt_ksing<T: AsRef<[u8]>>(data: T, key: &[u8; 8]) -> Result<String> {
Ok(base64::encode(data)) Ok(base64::encode(data))
} }
pub fn decode_ekey(data: &str, key: &[u8; 8]) -> Result<String> { pub fn decode_ekey<T: AsRef<[u8]>>(data: T, key: &[u8; 8]) -> Result<String> {
let decoded = decrypt_ksing(data, key)?; let decoded = decrypt_ksing(data, key)?;
Ok(decoded[16..].to_string()) Ok(decoded[16..].to_string())
} }

View File

@ -135,7 +135,7 @@ pub struct CipherBoDian(QMCv2Cipher);
impl CipherBoDian { impl CipherBoDian {
pub fn new<T: AsRef<[u8]>>(ekey: T) -> Result<Self> { pub fn new<T: AsRef<[u8]>>(ekey: T) -> Result<Self> {
let ekey = des::decode_ekey(&ekey, &SECRET_KEY)?; let ekey = des::decode_ekey(ekey, &SECRET_KEY)?;
let cipher = CipherV2::new_from_ekey(ekey.as_str())?; let cipher = CipherV2::new_from_ekey(ekey.as_str())?;
Ok(Self(cipher)) Ok(Self(cipher))
} }