Build CRC Table - CSharp System.Security.Cryptography

CSharp examples for System.Security.Cryptography:CRC

Description

Build CRC Table

Demo Code


using System.Text;
using System.Security.Cryptography;
using System.IO;/*from  w w w.  j  a  v  a 2s  .c o  m*/
using System.Collections;

public class Main{
        protected static uint[] BuildCRC32Table(uint ulPolynomial)
        {
            var numArray = new uint[256];
            for (var index1 = 0; index1 < 256; ++index1)
            {
                var num = (uint) index1;
                for (var index2 = 8; index2 > 0; --index2)
                {
                    if (((int) num & 1) == 1)
                        num = num >> 1 ^ ulPolynomial;
                    else
                        num >>= 1;
                }
                numArray[index1] = num;
            }
            return numArray;
        }
}

Related Tutorials