mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-06 12:58:45 +08:00
Add HaikuoCrypt (untested)
This commit is contained in:
@@ -175,6 +175,7 @@ enum CryptType {
|
||||
AkabeiCrypt {
|
||||
seed: u32,
|
||||
},
|
||||
HaikuoCrypt,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
@@ -274,6 +275,7 @@ impl Schema {
|
||||
CryptType::SourireCrypt => Box::new(SourireCrypt::new(self.base.clone())),
|
||||
CryptType::HibikiCrypt => Box::new(HibikiCrypt::new(self.base.clone())),
|
||||
CryptType::AkabeiCrypt { seed } => Box::new(AkabeiCrypt::new(self.base.clone(), *seed)),
|
||||
CryptType::HaikuoCrypt => Box::new(HaikuoCrypt::new(self.base.clone())),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1148,6 +1150,20 @@ impl<R: Read> Read for AkabeiCryptReader<R> {
|
||||
}
|
||||
}
|
||||
|
||||
seek_crypt_filehash_key_impl!(HaikuoCrypt, HaikuoCryptReader<T>);
|
||||
|
||||
impl<R: Read> Read for HaikuoCryptReader<R> {
|
||||
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
|
||||
let readed = self.inner.read(buf)?;
|
||||
let key = (self.key ^ (self.key >> 8)) as u8;
|
||||
for t in (&mut buf[..readed]).iter_mut() {
|
||||
*t ^= key;
|
||||
}
|
||||
self.pos += readed as u64;
|
||||
Ok(readed)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialize_crypt() {
|
||||
for (key, schema) in CRYPT_SCHEMA.iter() {
|
||||
|
||||
Reference in New Issue
Block a user