From 47078aea8ce1bfc28c9d56e94300edeb43cb6d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Tue, 27 Jan 2026 09:11:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(decrypt):=20=E4=BF=AE=E5=A4=8D=E8=A7=A3?= =?UTF-8?q?=E5=AF=86=E8=BF=87=E7=A8=8B=E4=B8=AD=E7=9A=84IV=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/encryption/spiral.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/encryption/spiral.rs b/src/encryption/spiral.rs index 25080cb..b898e18 100644 --- a/src/encryption/spiral.rs +++ b/src/encryption/spiral.rs @@ -45,10 +45,16 @@ pub fn decrypt(data: String) -> Result { let data = data[1..].to_string(); let key_seed = data[0..20].to_string(); let key = gen_key(&key_seed); - let iv: [u8; 16] = key[0..16].try_into().unwrap(); - let decryptor = AesDecryptor::new(&key.into(), &iv.into()); + let encrypted_data = crate::serialize::from_base64_str(&data[20..]) .map_err(|_| SpiralCipherError::CorruptedCipherData)?; + + // 使用key的前16字节作为IV(与Go版本PrefixIVGenerator对应) + let iv: [u8; 16] = key[0..16] + .try_into() + .map_err(|_| SpiralCipherError::CorruptedCipherData)?; + + let decryptor = AesDecryptor::new(&key.into(), &iv.into()); let decrypted_data = decryptor .decrypt_padded_vec_mut::(encrypted_data.as_slice()) .map_err(|e| {