Update 'libsharperang/DataTransforms.cs'

This commit is contained in:
Maff 2019-09-10 09:29:15 +00:00
parent 49b6ef53a5
commit d9df857328
1 changed files with 0 additions and 12 deletions

View File

@ -3,31 +3,19 @@ using Crc;
namespace libsharperang {
public class DataTransforms {
/*public class CrcSum : Crc32Base {
public uint CrcKey;
public CrcSum(uint Mangled, uint Key) : base(0x04c11db7, Mangled, 0xffffffff, true, true) => CrcKey=Key;
}
public CrcSum CRC;*/
public CRC32 hasher;
private uint MagicNumber=0x35769521;
//public bool IsCrcInitialised() => (CRC!=null);
public bool IsCrcInitialised() => (hasher!=null && hasher.Initialised);
//public void InitialiseCrc() => CRC=new CrcSum(Bludgeon(0x77c40d4d^0x35769521), 0x77c40d4d);
//public void InitialiseCrc(uint Key) => CRC=new CrcSum(Bludgeon(Key), Key);
public void InitialiseCrc(uint Key = 0x35769521) {
if (hasher==null || (hasher.Initialised && hasher.Initial != Key)) hasher=new CRC32(Key);
Console.WriteLine("{0:X}", hasher.Initial);
hasher.Initialise();
}
public byte[] GetHashSum(byte[] data) {
if (!IsCrcInitialised()) InitialiseCrc();
//return CRC.ComputeHash(data);
return BitConverter.GetBytes(hasher.GetChecksum(data));
}
public uint GetCrcKey() {
if (!IsCrcInitialised()) InitialiseCrc();
//return CRC.CrcKey;
return hasher.Initial == MagicNumber ? hasher.Initial : hasher.Initial ^ MagicNumber;
}
public byte[] GetCrcKeyBytes() {