/// <summary> /// Computes CRC-16 (IEEE 802.3) digest from given data. /// </summary> /// <param name="value">Value.</param> /// <param name="index">A 32-bit integer that represents the index at which data begins.</param> /// <param name="length">A 32-bit integer that represents the number of elements.</param> public static short ComputeCrc(byte[] value, int index, int length) { Crc16 crc = Crc16.GetIeee(); crc.Append(value, index, length); return(crc.Digest); }
/// <summary> /// Computes CRC-16 (IEEE 802.3) digest from given data. /// </summary> /// <param name="value">Unicode text for performing hash functions.</param> /// <param name="useAsciiEncoding">If True, ASCII encoding is used instead of Unicode.</param> public static short ComputeCrc(string value, bool useAsciiEncoding) { Crc16 crc = Crc16.GetIeee(); crc.Append(value, useAsciiEncoding); return(crc.Digest); }
/// <summary> /// Computes CRC-16 (IEEE 802.3) digest from given data. /// </summary> /// <param name="value">Value.</param> public static short ComputeCrc(byte[] value) { Crc16 crc = Crc16.GetIeee(); crc.Append(value); return(crc.Digest); }
public void Crc16_Arc() { string expected = "178C"; Crc16 actualCrc = Crc16.GetArc(); actualCrc.Append("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", true); string actual = actualCrc.Digest.ToString("X4"); Assert.AreEqual(expected, actual); }
public void TestCrc16(string name, ushort polynomial, ushort initialState, ushort xorOutput, bool reverseInput, bool reverseOutput, ushort check) { using (Crc16 crc = new Crc16(polynomial, initialState, xorOutput, reverseInput, reverseOutput)) { crc.Initialize(); var bytes = Encoding.UTF8.GetBytes(data); for (int i = 0; i < bytes.Length; i++) { crc.Append(bytes[i]); } ushort output = crc.CurrentOutput; Assert.AreEqual(check, output, 0); } }