(DameganeCrypt): another decryption scheme.

This commit is contained in:
morkt 2015-08-11 07:06:00 +04:00
parent 0db69aea4e
commit c5aee52d96

View File

@ -92,6 +92,7 @@ namespace GameRes.Formats.KiriKiri
{ arcStrings.ArcNoEncryption, NoCryptAlgorithm },
{ "Cafe Sourire", new XorCrypt (0xcd) },
{ "Coμ", new ComyuCrypt() },
{ "Damegane", new DameganeCrypt() },
{ "Fate/hollow ataraxia", new FateHACrypt() },
{ "Fate/stay night", new FateCrypt() },
{ "Imouto Style", new ImoutoStyleCrypt() },
@ -1055,4 +1056,31 @@ NextEntry:
}
}
}
internal class DameganeCrypt : ICrypt
{
public override byte Decrypt (Xp3Entry entry, long offset, byte value)
{
if (0 != (offset & 1))
return (byte)(value ^ entry.Hash);
else
return (byte)(value ^ offset);
}
public override void Decrypt (Xp3Entry entry, long offset, byte[] values, int pos, int count)
{
for (int i = 0; i < count; ++i, ++offset)
{
if (0 != (offset & 1))
values[pos+i] ^= (byte)entry.Hash;
else
values[pos+i] ^= (byte)offset;
}
}
public override void Encrypt (Xp3Entry entry, long offset, byte[] values, int pos, int count)
{
Decrypt (entry, offset, values, pos, count);
}
}
}