Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Crc32.cs
2{
6 public static class Crc32
7 {
8 private static readonly uint[] table = CreateTable();
9
10 private static uint[] CreateTable()
11 {
12 uint[] Result = new uint[256];
13
14 for (uint i = 0; i < 256; i++)
15 {
16 uint c = i;
17
18 for (int k = 0; k < 8; k++)
19 c = (c & 1) != 0 ? 0xedb88320u ^ (c >> 1) : c >> 1;
20
21 Result[i] = c;
22 }
23
24 return Result;
25 }
26
33 public static uint Compute(byte[] Data)
34 {
35 uint Crc = 0xffffffff;
36
37 foreach (byte b in Data)
38 Crc = table[(byte)(Crc ^ b)] ^ (Crc >> 8);
39
40 return ~Crc;
41 }
42
49 public static uint Update(uint Crc, byte Value)
50 {
51 return table[(byte)(Crc ^ Value)] ^ (Crc >> 8);
52 }
53
54 }
55}
Static class for computing CRC-32 checksums.
Definition: Crc32.cs:7
static uint Update(uint Crc, byte Value)
Updates an existing CRC value with one byte (standard CRC-32 algorithm).
Definition: Crc32.cs:49
static uint Compute(byte[] Data)
Computes the CRC-32 of a byte array (polynomial 0xEDB88320, init = 0xFFFFFFFF, xor out = 0xFFFFFFFF).
Definition: Crc32.cs:33