function createCrc64
createCrc64(polynomial: bigint): (data: Uint8Array) => bigint

Creates a CRC64 function for the given polynomial.

Uses init=0xffffffffffffffff and xor=0xffffffffffffffff. With CRC64_ECMA_POLYNOMIAL this matches CRC-64/XZ; other catalogue variants (notably CRC-64/ECMA-182 proper, which uses init=0/xor=0) need different init/xor. BigInt is used for 64-bit precision.

Examples

Example 1

import { assertEquals } from "@std/assert";
import { createCrc64, CRC64_ECMA_POLYNOMIAL } from "@hertzg/crc/crc64";

const crc64 = createCrc64(CRC64_ECMA_POLYNOMIAL);

assertEquals(crc64(new TextEncoder().encode("123456789")), 0x995dc9bbdf1939fan);

Parameters

polynomial: bigint

The CRC64 polynomial to use (must be BigInt)

Return Type

(data: Uint8Array) => bigint

A function that calculates CRC64 for given data

Usage

import { createCrc64 } from "crc64.ts";