Add Kano2Crypt

This commit is contained in:
2026-05-02 17:12:13 +08:00
parent ed56ef1e39
commit c298e1c1e1
2 changed files with 23 additions and 0 deletions

View File

@@ -2511,6 +2511,10 @@
"With Ribbon": { "With Ribbon": {
"$type": "SourireCrypt" "$type": "SourireCrypt"
}, },
"xx na Kanojo no Tsukurikata 2": {
"$type": "Kano2Crypt",
"Title": "××な彼女のつくりかた2"
},
"Yakimochi Stream": { "Yakimochi Stream": {
"$type": "MadoCrypt", "$type": "MadoCrypt",
"Seed": 4076513695, "Seed": 4076513695,

View File

@@ -257,6 +257,7 @@ enum CryptType {
key3: u64, key3: u64,
}, },
SyangrilaSmartCrypt, SyangrilaSmartCrypt,
Kano2Crypt,
} }
#[derive(Clone, Debug, Deserialize)] #[derive(Clone, Debug, Deserialize)]
@@ -406,6 +407,7 @@ impl Schema {
*key3, *key3,
)), )),
CryptType::SyangrilaSmartCrypt => Box::new(SyangrilaSmartCrypt::new(self.base.clone())), CryptType::SyangrilaSmartCrypt => Box::new(SyangrilaSmartCrypt::new(self.base.clone())),
CryptType::Kano2Crypt => Box::new(Kano2Crypt::new(self.base.clone())),
}) })
} }
} }
@@ -2203,6 +2205,23 @@ impl<R: Read> Read for SyangrilaSmartCryptReader<R> {
} }
} }
seek_crypt_filehash_key_u8_impl!(Kano2Crypt, Kano2CryptReader<T>);
impl<R: Read> Read for Kano2CryptReader<R> {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
let readed = self.inner.read(buf)?;
let mut offset = (self.seg_start + self.pos) % 8;
for t in buf[..readed].iter_mut() {
if offset == 0 {
*t ^= self.key;
}
offset = (offset + 1) % 8;
}
self.pos += readed as u64;
Ok(readed)
}
}
#[test] #[test]
fn test_deserialize_crypt() { fn test_deserialize_crypt() {
for (key, schema) in CRYPT_SCHEMA.iter() { for (key, schema) in CRYPT_SCHEMA.iter() {