Crc32 implementation moved to separate file.

this implementation uses 'normal' polynomial representation unlike Crc32
defined in GameRes.
This commit is contained in:
morkt
2016-08-19 09:29:06 +04:00
parent 8808b54c88
commit 303a8551b0
4 changed files with 91 additions and 59 deletions

View File

@@ -35,6 +35,7 @@ using System.Runtime.InteropServices;
using GameRes.Formats.Strings;
using GameRes.Formats.Properties;
using GameRes.Cryptography;
using GameRes.Utility;
namespace GameRes.Formats.CatSystem
{
@@ -67,16 +68,7 @@ namespace GameRes.Formats.CatSystem
uint key = 0xffffffff;
foreach (var c in pass_bytes)
{
uint val = (uint)c << 24;
key ^= val;
for (int i = 0; i < 8; ++i)
{
bool carry = 0 != (key & 0x80000000);
key <<= 1;
if (carry)
key ^= 0x4C11DB7;
}
key = ~key;
key = ~Crc32Normal.Table[(key >> 24) ^ c] ^ (key << 8);
}
return key;
}