예제 #1
0
        public static UInt32 CRC32(byte[] data)
        {
            var crc = CrcAlgorithm.CreateCrc32Jamcrc();

            crc.Append(data);
            return((UInt32)crc.ToUInt64());
        }
예제 #2
0
        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)));
        }
예제 #3
0
        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());
        }
예제 #4
0
 public static Parameters Get(CrcAlgorithm algorithm) => Dictionary[algorithm];