// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics
{
internal static class Crc32ReflectedTable
{
internal static uint[] Generate(uint reflectedPolynomial)
{
uint[] table = new uint[256];
for (int i = 0; i < 256; i++)
{
uint val = (uint)i;
for (int j = 0; j < 8; j++)
{
if ((val & 0b0000_0001) == 0)
{
val >>= 1;
}
else
{
val = (val >> 1) ^ reflectedPolynomial;
}
}
table[i] = val;
}
return table;
}
}
}
|