From c298e1c1e1e5b591e42ff0a8b6c329a64106c628 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sat, 2 May 2026 17:12:13 +0800 Subject: [PATCH] Add Kano2Crypt --- msg_tool_xp3data/crypt.json | 4 ++++ src/scripts/kirikiri/archive/xp3/crypt/mod.rs | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/msg_tool_xp3data/crypt.json b/msg_tool_xp3data/crypt.json index bd8c91d..6405c5c 100644 --- a/msg_tool_xp3data/crypt.json +++ b/msg_tool_xp3data/crypt.json @@ -2511,6 +2511,10 @@ "With Ribbon": { "$type": "SourireCrypt" }, + "xx na Kanojo no Tsukurikata 2": { + "$type": "Kano2Crypt", + "Title": "××な彼女のつくりかた2" + }, "Yakimochi Stream": { "$type": "MadoCrypt", "Seed": 4076513695, diff --git a/src/scripts/kirikiri/archive/xp3/crypt/mod.rs b/src/scripts/kirikiri/archive/xp3/crypt/mod.rs index 98023c6..3969652 100644 --- a/src/scripts/kirikiri/archive/xp3/crypt/mod.rs +++ b/src/scripts/kirikiri/archive/xp3/crypt/mod.rs @@ -257,6 +257,7 @@ enum CryptType { key3: u64, }, SyangrilaSmartCrypt, + Kano2Crypt, } #[derive(Clone, Debug, Deserialize)] @@ -406,6 +407,7 @@ impl Schema { *key3, )), CryptType::SyangrilaSmartCrypt => Box::new(SyangrilaSmartCrypt::new(self.base.clone())), + CryptType::Kano2Crypt => Box::new(Kano2Crypt::new(self.base.clone())), }) } } @@ -2203,6 +2205,23 @@ impl Read for SyangrilaSmartCryptReader { } } +seek_crypt_filehash_key_u8_impl!(Kano2Crypt, Kano2CryptReader); + +impl Read for Kano2CryptReader { + fn read(&mut self, buf: &mut [u8]) -> std::io::Result { + 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] fn test_deserialize_crypt() { for (key, schema) in CRYPT_SCHEMA.iter() {