Add HighRunningCrypt (untested)

This commit is contained in:
2026-04-10 18:41:00 +08:00
parent 20b3c14807
commit dc4cac84f4
2 changed files with 29 additions and 0 deletions

View File

@@ -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() {