Exemple #1
0
 /// <summary>Creates a new configuration of the <see cref="CrcConfig64"/> struct.</summary>
 /// <inheritdoc cref="CrcConfig(int, byte, byte, byte, bool, bool, byte, byte, bool)"/>
 public CrcConfig64(int bits, ulong check, ulong poly, ulong init = default, bool refIn = false, bool refOut = false, ulong xorOut = default, ulong mask = default, bool skipValidation = false)
 {
     if (bits < 8)
     {
         throw new ArgumentOutOfRangeException(nameof(bits), bits, null);
     }
     if (sizeof(ulong) < (int)MathF.Floor(bits / 8f))
     {
         throw new ArgumentException(ExceptionMessages.ArgumentBitsTypeRatioInvalid);
     }
     if (mask == default)
     {
         mask = CreateMask(bits);
     }
     Bits   = bits;
     Check  = check;
     Poly   = poly;
     Init   = init;
     RefIn  = refIn;
     RefOut = refOut;
     XorOut = xorOut;
     Mask   = mask;
     Table  = CreateTable(bits, poly, mask, refIn);
     if (!skipValidation)
     {
         CrcConfig.ThrowIfInvalid(this);
     }
 }
Exemple #2
0
 /// <summary>Creates a new configuration of the <see cref="CrcConfigBeyond"/> struct.</summary>
 /// <inheritdoc cref="CrcConfig(int, byte, byte, byte, bool, bool, byte, byte, bool)"/>
 public CrcConfigBeyond(int bits, BigInteger check, BigInteger poly, BigInteger init = default, bool refIn = false, bool refOut = false, BigInteger xorOut = default, BigInteger mask = default, bool skipValidation = false)
 {
     if (bits < 8)
     {
         throw new ArgumentOutOfRangeException(nameof(bits), bits, null);
     }
     if (mask == default)
     {
         mask = CreateMask(bits);
     }
     Bits   = bits;
     Check  = check;
     Poly   = poly;
     Init   = init;
     RefIn  = refIn;
     RefOut = refOut;
     XorOut = xorOut;
     Mask   = mask;
     Table  = CreateTable(bits, poly, mask, refIn);
     if (!skipValidation)
     {
         CrcConfig.ThrowIfInvalid(this);
     }
 }
Exemple #3
0
 /// <inheritdoc/>
 public bool IsValid(out ulong current) =>
 CrcConfig.IsValid(this, out current);
Exemple #4
0
 /// <inheritdoc/>
 public bool IsValid(out BigInteger current) =>
 CrcConfig.IsValid(this, out current);