public static UInt32 CRC32(byte[] data) { var crc = CrcAlgorithm.CreateCrc32Jamcrc(); crc.Append(data); return((UInt32)crc.ToUInt64()); }
public static string ComputeHash(byte[] bytes, CrcAlgorithm crcAlgorithm) { Parameters parameters = CrcStdParams.Get(crcAlgorithm); Crc crc = new Crc(parameters); IEnumerable <byte> result = crc.ComputeHash(bytes).Take(parameters.HashSize / 8).Reverse(); return(HexUtil.ConvertHexStringArrayToHexString(HexUtil.ConvertByteArrayToHexStringArray(result))); }
private static void Main(String[] args) { // Create a new instance of Crc using the algorithm of your choice var crc = CrcAlgorithm.CreateCrc16CcittFalse(); // Give it some bytes to chew on - you can call this multiple times if needed crc.Append(Encoding.ASCII.GetBytes("Hurray for cake!")); // Get the output - as a hex string, byte array or unsigned integer Console.WriteLine(crc.ToHexString()); }
public static Parameters Get(CrcAlgorithm algorithm) => Dictionary[algorithm];