Exemplo n.º 1
0
        public static byte PolynomialCRC(byte[] data, byte polynomial)
        {
            if (data == null || data.Length == 0)
            {
                throw new ArgumentException(nameof(data), "PolynomialCRC: Data to CRC is invalid.");
            }
            if (ChecksumCalculator._lookupTable == null || ChecksumCalculator._lookupTable != null && (int)ChecksumCalculator._polynomial != (int)polynomial)
            {
                ChecksumCalculator.PopulateLookupTable(polynomial);
            }
            byte num1 = 0;

            foreach (byte num2 in data)
            {
                num1 = ChecksumCalculator._lookupTable[(int)num1 ^ (int)num2];
            }
            return(num1);
        }
Exemplo n.º 2
0
 public static byte XOR(string data) => ChecksumCalculator.XOR(Encoding.UTF8.GetBytes(data));