1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-11-22 13:42:47 +00:00

Minor refactoring of TSC decryption [ci skip]

This commit is contained in:
biroder 2023-04-10 16:23:46 +03:00 committed by GitHub
parent 0ccbbefbed
commit 72a2ada0b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
pub fn decrypt_tsc(buf: &mut [u8]) {
let half = buf.len() / 2;
let key = if let Some(0) = buf.get(half) { 0xf9 } else { (-(*buf.get(half).unwrap() as isize)) as u8 };
let key = if let Some(0) = buf.get(half) { 0x7 } else { *buf.get(half).unwrap() };
log::info!("Decrypting TSC using key {:#x}", key);
for (idx, byte) in buf.iter_mut().enumerate() {
@ -8,6 +8,6 @@ pub fn decrypt_tsc(buf: &mut [u8]) {
continue;
}
*byte = byte.wrapping_add(key);
*byte = byte.wrapping_sub(key);
}
}