(MrgOpener.Decrypt): added array range parameters.

This commit is contained in:
morkt 2015-11-23 21:29:35 +04:00
parent 203172be77
commit bcc3583885

View File

@ -75,7 +75,7 @@ namespace GameRes.Formats.FC01
var key = GuessKey (file, index);
if (null == key)
throw new UnknownEncryptionScheme();
Decrypt (index, key.Value);
Decrypt (index, 0, index.Length, key.Value);
int current_offset = 0;
uint next_offset = LittleEndian.ToUInt32 (index, current_offset+0x1C);
@ -132,14 +132,13 @@ namespace GameRes.Formats.FC01
return input;
}
static public void Decrypt (byte[] data, int key)
static public void Decrypt (byte[] data, int index, int length, int key)
{
int remaining = data.Length;
for (int i = 0; i < data.Length; ++i)
while (length > 0)
{
var v = data[i];
data[i] = (byte)((v << 1 | v >> 7) ^ key);
key += remaining--;
var v = data[index];
data[index++] = (byte)((v << 1 | v >> 7) ^ key);
key += length--;
}
}