1
0

style(p4, p9): fix style issue

This commit is contained in:
2025-09-02 12:05:26 +08:00
parent dd3d486094
commit 27e7137418
2 changed files with 5 additions and 4 deletions

View File

@@ -13,12 +13,12 @@ fn main() -> Result<(), Box<dyn Error>> {
// 对密文的每个字节应用异或操作,得到明文
let plaintext: Vec<u8> = cipher_bytes.iter().map(|&byte| byte ^ key).collect();
for i in 0..=(plaintext.iter().len() - window_size) {
if let Ok(text) = std::str::from_utf8(&plaintext[i..i + window_size]) {
if is_valid_english(text, None) {
if let Ok(text) = std::str::from_utf8(&plaintext[i..i + window_size])
&& is_valid_english(text, None)
{
println!("Found valid sentence with key {key}: {text}");
}
}
}
// 尝试将字节转换为字符串
}

View File

@@ -15,6 +15,7 @@ fn pkcs7_padding(data: &mut Vec<u8>, block_size: usize) {
data.extend(vec![padding_length as u8; padding_length]);
}
#[allow(dead_code)]
fn pkcs7_unpadding(input: &[u8]) -> Result<Vec<u8>> {
if input.is_empty() {
return Err(anyhow!("Input cannot be empty"));