(XP3): another encryption algorithm.

This commit is contained in:
morkt
2018-10-25 16:49:28 +04:00
parent 00ea0d3e4e
commit 8c758668f2

View File

@@ -1270,4 +1270,27 @@ namespace GameRes.Formats.KiriKiri
Decrypt (entry, offset, buffer, pos, count);
}
}
[Serializable]
public class FestivalCrypt : ICrypt
{
public override byte Decrypt (Xp3Entry entry, long offset, byte value)
{
return (byte)(value ^ (entry.Hash >> 7) ^ 0xFF);
}
public override void Decrypt (Xp3Entry entry, long offset, byte[] data, int pos, int count)
{
byte key = (byte)~(entry.Hash >> 7);
for (int i = 0; i < count; ++i)
{
data[pos+i] ^= key;
}
}
public override void Encrypt (Xp3Entry entry, long offset, byte[] data, int pos, int count)
{
Decrypt (entry, offset, data, pos, count);
}
}
}