using System.Runtime.Remoting.Metadata.W3cXsd2001;
public static string CalcCRC16(string strInput) {
byte[] data = GetBytesFromHexString(strInput);
for (int i = 0; i < data.Length; i++) {
crc ^= (ushort)(data[i] << 8);
for (int j = 0; j < 8; j++) {
crc = (ushort)((crc << 1) ^ 0x1021);
return crc.ToString("X4");
public static Byte[] GetBytesFromHexString(string strInput) {
Byte[] bytArOutput = new Byte[] { };
if (!string.IsNullOrEmpty(strInput) && strInput.Length % 2 == 0) {
SoapHexBinary hexBinary = null;
hexBinary = SoapHexBinary.Parse(strInput);
bytArOutput = hexBinary.Value;
public static void Main()
Console.WriteLine("Hello World");
string result = CalcCRC16("190CC00000171B0B04100021000000A7F600190CC00000030F110140");
Console.WriteLine(result);