mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 15:44:00 +08:00
(WARC): added PostAdlerCrypt/PreAdlerCrypt.
This commit is contained in:
parent
c6f04a06e6
commit
0c4dc5a679
@ -1054,7 +1054,20 @@ namespace GameRes.Formats.ShiinaRio
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class AdlerCrypt : IDecryptExtra
|
public class AdlerCrypt
|
||||||
|
{
|
||||||
|
internal void Transform (byte[] data, int index, int length)
|
||||||
|
{
|
||||||
|
uint key = Adler32.Compute (data, index, length);
|
||||||
|
data[index + 0x200] ^= (byte)key;
|
||||||
|
data[index + 0x201] ^= (byte)(key >> 8);
|
||||||
|
data[index + 0x202] ^= (byte)(key >> 16);
|
||||||
|
data[index + 0x203] ^= (byte)(key >> 24);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class PostAdlerCrypt : AdlerCrypt, IDecryptExtra
|
||||||
{
|
{
|
||||||
public void Decrypt (byte[] data, int index, uint length, uint flags)
|
public void Decrypt (byte[] data, int index, uint length, uint flags)
|
||||||
{
|
{
|
||||||
@ -1067,14 +1080,21 @@ namespace GameRes.Formats.ShiinaRio
|
|||||||
if (length >= 0x400 && (flags & 0x104) == 0x104)
|
if (length >= 0x400 && (flags & 0x104) == 0x104)
|
||||||
Transform (data, index, 0xFF);
|
Transform (data, index, 0xFF);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Transform (byte[] data, int index, int length)
|
[Serializable]
|
||||||
|
public class PreAdlerCrypt : AdlerCrypt IDecryptExtra
|
||||||
|
{
|
||||||
|
public void Decrypt (byte[] data, int index, uint length, uint flags)
|
||||||
{
|
{
|
||||||
uint key = Adler32.Compute (data, index, length);
|
if (length >= 0x400 && (flags & 0x202) == 0x202)
|
||||||
data[index + 0x200] ^= (byte)key;
|
Transform (data, index, 0xFF);
|
||||||
data[index + 0x201] ^= (byte)(key >> 8);
|
}
|
||||||
data[index + 0x202] ^= (byte)(key >> 16);
|
|
||||||
data[index + 0x203] ^= (byte)(key >> 24);
|
public void Encrypt (byte[] data, int index, uint length, uint flags)
|
||||||
|
{
|
||||||
|
if (length >= 0x400 && (flags & 0x102) == 0x102)
|
||||||
|
Transform (data, index, 0xFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user