CRC64Params.hex constructor

CRC64Params.hex({
  1. required String poly,
  2. bool reversed = false,
  3. String seed = "0000000000000000",
  4. String xorOut = "0000000000000000",
})

Create a custom polynomial from hexadecimal

Parameters:

  • poly: the polynomial in hexadecimal (MSB first)
  • seed: initial counter to start from (MSB first)
  • xorOut: the value to xor with the final output (MSB first)
  • reversed: to use reversed or reflected polynomial and input

Implementation

factory CRC64Params.hex({
  required String poly,
  bool reversed = false,
  String seed = "0000000000000000",
  String xorOut = "0000000000000000",
}) {
  Uint8List p = fromHex(poly);
  Uint8List s = fromHex(seed);
  Uint8List x = fromHex(xorOut);
  int high = (p[0] << 24) ^ (p[1] << 16) ^ (p[2] << 8) ^ (p[3]);
  int low = (p[4] << 24) ^ (p[5] << 16) ^ (p[6] << 8) ^ (p[7]);
  int seedHigh = (s[0] << 24) ^ (s[1] << 16) ^ (s[2] << 8) ^ (s[3]);
  int seedLow = (s[4] << 24) ^ (s[5] << 16) ^ (s[6] << 8) ^ (s[7]);
  int xorOutHigh = (x[0] << 24) ^ (x[1] << 16) ^ (x[2] << 8) ^ (x[3]);
  int xorOutLow = (x[4] << 24) ^ (x[5] << 16) ^ (x[6] << 8) ^ (x[7]);
  return CRC64Params._(
    poly,
    high,
    low,
    reversed,
    seedHigh,
    seedLow,
    xorOutHigh,
    xorOutLow,
  );
}