public void crc32Test() { // Use the Assert class to test conditions Crc32 crc32 = new Crc32(); string hash = ""; var str = BinUtil.StringToBytes("The quick brown fox jumps over the lazy dog"); var b = crc32.ComputeHash(str); Console.WriteLine("CRC-32 is {0}", hash); Assert.AreEqual("414FA339", BinUtil.BytesToHexString(b)); }
byte[] CreateHeader(string dataStr, int bodyLen) { byte[] data = new byte[12]; magicNumber.CopyTo(data, 0); BinUtil.StringToBytes(dataStr).CopyTo(data, 2); var bodyLenByte = BitConverter.GetBytes(bodyLen); if (!BitConverter.IsLittleEndian) { Array.Reverse(bodyLenByte); } bodyLenByte.CopyTo(data, 8); return(data); }