mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-06 12:58:45 +08:00
Add HighRunningCrypt (untested)
This commit is contained in:
@@ -188,6 +188,7 @@ enum CryptType {
|
||||
zero_xor: u8,
|
||||
},
|
||||
YuzuCrypt,
|
||||
HighRunningCrypt,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
@@ -301,6 +302,7 @@ impl Schema {
|
||||
*zero_xor,
|
||||
)),
|
||||
CryptType::YuzuCrypt => Box::new(YuzuCrypt::new(self.base.clone())),
|
||||
CryptType::HighRunningCrypt => Box::new(HighRunningCrypt::new(self.base.clone())),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1324,6 +1326,25 @@ impl<R: Read> Read for YuzuCryptReader<R> {
|
||||
}
|
||||
}
|
||||
|
||||
seek_crypt_filehash_key_u8_impl!(HighRunningCrypt, HighRunningCryptReader<T>);
|
||||
|
||||
impl<R: Read> Read for HighRunningCryptReader<R> {
|
||||
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
|
||||
let readed = self.inner.read(buf)?;
|
||||
let key = self.key as u64;
|
||||
if key != 0 {
|
||||
for (i, t) in (&mut buf[..readed]).iter_mut().enumerate() {
|
||||
let offset = self.seg_start + self.pos + i as u64;
|
||||
if offset % key != 0 {
|
||||
*t ^= self.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