2025-03-02 01:41:12 +01:00
/ * *
* @ author r4mos [ 2 k95ljkhg @ mozmail . com ]
* @ copyright Crown Copyright 2025
* @ license Apache - 2.0
* /
import Operation from "../Operation.mjs" ;
import OperationError from "../errors/OperationError.mjs" ;
/ * *
* CRC Checksum operation
* /
class CRCChecksum extends Operation {
/ * *
* CRCChecksum constructor
* /
constructor ( ) {
super ( ) ;
this . name = "CRC Checksum" ;
this . module = "Default" ;
this . description = "A Cyclic Redundancy Check (<b>CRC</b>) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data." ;
this . infoURL = "https://wikipedia.org/wiki/Cyclic_redundancy_check" ;
this . inputType = "ArrayBuffer" ;
this . outputType = "string" ;
this . args = [
{
name : "Algorithm" ,
2025-03-03 17:15:26 +01:00
type : "argSelector" ,
2025-03-02 01:41:12 +01:00
value : [
2025-03-03 17:15:26 +01:00
{
name : "Custom" ,
on : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-3/GSM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-3/ROHC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-4/G-704" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-4/INTERLAKEN" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-4/ITU" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-5/EPC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-5/EPC-C1G2" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-5/G-704" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-5/ITU" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-5/USB" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-6/CDMA2000-A" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-6/CDMA2000-B" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-6/DARC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-6/G-704" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-6/GSM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-6/ITU" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-7/MMC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-7/ROHC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-7/UMTS" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/8H2F" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/AES" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/AUTOSAR" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/BLUETOOTH" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/CDMA2000" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/DARC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/DVB-S2" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/EBU" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/GSM-A" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/GSM-B" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/HITAG" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/I-432-1" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/I-CODE" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/ITU" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/LTE" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/MAXIM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/MAXIM-DOW" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/MIFARE-MAD" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/NRSC-5" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/OPENSAFETY" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/ROHC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/SAE-J1850" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/SAE-J1850-ZERO" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/SMBUS" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/TECH-3250" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-8/WCDMA" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-10/ATM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-10/CDMA2000" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-10/GSM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-10/I-610" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-11/FLEXRAY" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-11/UMTS" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-12/3GPP" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-12/CDMA2000" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-12/DECT" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-12/GSM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-12/UMTS" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-13/BBC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-14/DARC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-14/GSM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-15/CAN" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-15/MPT1327" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/A" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/ACORN" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/ARC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/AUG-CCITT" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/AUTOSAR" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/B" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/BLUETOOTH" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/BUYPASS" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/CCITT" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/CCITT-FALSE" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/CCITT-TRUE" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/CCITT-ZERO" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/CDMA2000" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/CMS" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/DARC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/DDS-110" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/DECT-R" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/DECT-X" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/DNP" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/EN-13757" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/EPC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/EPC-C1G2" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/GENIBUS" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/GSM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/I-CODE" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/IBM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/IBM-3740" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/IBM-SDLC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/IEC-61158-2" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/ISO-HDLC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/ISO-IEC-14443-3-A" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/ISO-IEC-14443-3-B" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/KERMIT" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/LHA" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/LJ1200" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/LTE" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/M17" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/MAXIM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/MAXIM-DOW" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/MCRF4XX" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/MODBUS" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/NRSC-5" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/OPENSAFETY-A" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/OPENSAFETY-B" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/PROFIBUS" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/RIELLO" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/SPI-FUJITSU" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/T10-DIF" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/TELEDISK" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/TMS37157" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/UMTS" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/USB" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/V-41-LSB" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/V-41-MSB" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/VERIFONE" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/X-25" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/XMODEM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-16/ZMODEM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-17/CAN-FD" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-21/CAN-FD" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-24/BLE" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-24/FLEXRAY-A" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-24/FLEXRAY-B" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-24/INTERLAKEN" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-24/LTE-A" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-24/LTE-B" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-24/OPENPGP" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-24/OS-9" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-30/CDMA" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-31/PHILIPS" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/AAL5" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/ADCCP" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/AIXM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/AUTOSAR" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/BASE91-C" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/BASE91-D" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/BZIP2" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/C" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/CASTAGNOLI" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/CD-ROM-EDC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/CKSUM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/D" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/DECT-B" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/INTERLAKEN" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/ISCSI" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/ISO-HDLC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/JAMCRC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/MEF" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/MPEG-2" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/NVME" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/PKZIP" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/POSIX" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/Q" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/SATA" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/V-42" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/XFER" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-32/XZ" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-40/GSM" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-64/ECMA-182" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-64/GO-ECMA" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-64/GO-ISO" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-64/MS" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-64/NVME" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-64/REDIS" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-64/WE" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-64/XZ" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
} ,
{
name : "CRC-82/DARC" ,
off : [ 1 , 2 , 3 , 4 , 5 , 6 ]
}
2025-03-02 01:41:12 +01:00
]
2025-03-03 17:15:26 +01:00
} ,
{
name : "Width (bits)" ,
type : "toggleString" ,
value : "0" ,
toggleValues : [ "Decimal" ]
} ,
{
name : "Polynomial" ,
type : "toggleString" ,
value : "0" ,
toggleValues : [ "Hex" ]
} ,
{
name : "Initialization" ,
type : "toggleString" ,
value : "0" ,
toggleValues : [ "Hex" ]
} ,
{
name : "Reflect input" ,
type : "option" ,
value : [ "True" , "False" ]
} ,
{
name : "Reflect output" ,
type : "option" ,
value : [ "True" , "False" ]
} ,
{
name : "Xor Output" ,
type : "toggleString" ,
value : "0" ,
toggleValues : [ "Hex" ]
2025-03-02 01:41:12 +01:00
}
] ;
}
/ * *
* Reverse the order of bits in a number
*
* @ param { BigInt } data
* @ param { BigInt } reflect
* /
reflectData ( data , reflect ) {
let value = 0 n ;
for ( let bit = 0 n ; bit < reflect ; bit ++ ) {
if ( ( data & 1 n ) === 1 n ) {
value |= ( 1 n << ( ( reflect - 1 n ) - bit ) ) ;
}
data >>= 1 n ;
}
return value ;
}
/ * *
* Performs the CRC Checksum calculation bit per bit without acceleration
*
* @ param { BigInt } width
* @ param { ArrayBuffer } input
* @ param { BigInt } poly
* @ param { BigInt } remainder
* @ param { boolean } reflectIn
* @ param { boolean } reflectOut
* @ param { BigInt } xorOut
* /
calculateCrcBitPerBit ( width , input , poly , remainder , reflectIn , reflectOut , xorOut ) {
const TOP _BIT = 1 n << ( width - 1 n ) ;
const MASK = ( 1 n << width ) - 1 n ;
for ( let byte of input ) {
byte = BigInt ( byte ) ;
if ( reflectIn ) {
byte = this . reflectData ( byte , 8 n ) ;
}
for ( let i = 0x80 n ; i !== 0 n ; i >>= 1 n ) {
let bit = remainder & TOP _BIT ;
remainder = ( remainder << 1 n ) & MASK ;
if ( ( byte & i ) !== 0 n ) {
bit ^= TOP _BIT ;
}
if ( bit !== 0 n ) {
remainder ^= poly ;
}
}
}
if ( reflectOut ) {
remainder = this . reflectData ( remainder , width ) ;
}
return remainder ^ xorOut ;
}
/ * *
* Generates the necessary table to speed up the calculation
*
* @ param { BigInt } width
* @ param { BigInt } poly
* @ param { BigInt } MASK
* @ param { BigInt } TOP _BIT
* /
generateTable ( width , poly , MASK , TOP _BIT ) {
const table = new Array ( 256 n ) ;
for ( let byte = 0 n ; byte < 256 n ; byte ++ ) {
let value = ( ( byte << width - 8 n ) & MASK ) ;
for ( let bit = 0 n ; bit < 8 n ; bit ++ ) {
value = ( value & TOP _BIT ) === 0 n ?
( ( value << 1 n ) & MASK ) :
( ( value << 1 n ) & MASK ) ^ poly ;
}
table [ byte ] = value ;
}
return table ;
}
/ * *
* Performs the CRC Checksum calculation byte per byte using a computed table to accelerate it
*
* @ param { BigInt } width
* @ param { ArrayBuffer } input
* @ param { BigInt } poly
* @ param { BigInt } remainder
* @ param { boolean } reflectIn
* @ param { boolean } reflectOut
* @ param { BigInt } xorOut
* /
calculateCrcBytePerByte ( width , input , poly , remainder , reflectIn , reflectOut , xorOut ) {
const TOP _BIT = 1 n << ( width - 1 n ) ;
const MASK = ( 1 n << width ) - 1 n ;
const TABLE = this . generateTable ( width , poly , MASK , TOP _BIT ) ;
for ( let byte of input ) {
byte = BigInt ( byte ) ;
if ( reflectIn ) {
byte = this . reflectData ( byte , 8 n ) ;
}
remainder ^= ( byte << width - 8 n ) & MASK ;
const INDEX = remainder >> width - 8 n ;
remainder = ( remainder << 8 n ) & MASK ;
remainder ^= TABLE [ INDEX ] ;
}
if ( reflectOut ) {
remainder = this . reflectData ( remainder , width ) ;
}
return remainder ^ xorOut ;
}
/ * *
* Calculates the CRC Checksum using Bigint ( https : //developer.mozilla.org/en-US/docs/Glossary/BigInt)
*
* @ param { BigInt } width
* @ param { ArrayBuffer } input
* @ param { BigInt } poly
* @ param { BigInt } init
* @ param { boolean } reflectIn
* @ param { boolean } reflectOut
* @ param { BigInt } xorOut
* /
crc ( width , input , poly , init , reflectIn , reflectOut , xorOut ) {
const VALUE = width < 8 n ?
this . calculateCrcBitPerBit ( width , input , poly , init , reflectIn , reflectOut , xorOut ) :
this . calculateCrcBytePerByte ( width , input , poly , init , reflectIn , reflectOut , xorOut ) ;
return VALUE . toString ( 16 ) . padStart ( Math . ceil ( Number ( width ) / 4 ) , "0" ) ;
}
2025-03-03 17:15:26 +01:00
/ * *
* Validates user input to perform a custom CRC
*
* @ param { Object } widthObject
* @ param { ArrayBuffer } input
* @ param { Object } polyObject
* @ param { Object } initObject
* @ param { Object } reflectInObject
* @ param { Object } reflectOutObject
* @ param { Object } xorOutObject
* /
custom ( widthObject , input , polyObject , initObject , reflectInObject , reflectOutObject , xorOutObject ) {
try {
const width = BigInt ( widthObject . string ) ;
const poly = BigInt ( "0x" + polyObject . string ) ;
const init = BigInt ( "0x" + initObject . string ) ;
2025-03-04 08:43:16 +01:00
const reflectIn = reflectInObject === "True" ;
const reflectOut = reflectOutObject === "True" ;
2025-03-03 17:15:26 +01:00
const xorOut = BigInt ( "0x" + xorOutObject . string ) ;
return this . crc ( width , input , poly , init , reflectIn , reflectOut , xorOut ) ;
} catch ( error ) {
throw new OperationError ( "Invalid custom CRC arguments" ) ;
}
}
2025-03-02 01:41:12 +01:00
/ * *
* Calculation of all known CRCs . Names and constants extracted from https : //reveng.sourceforge.io/crc-catalogue/all.htm
*
* @ param { ArrayBuffer } input
* @ param { Object [ ] } args
* @ returns { string }
* /
run ( input , args ) {
const algorithm = args [ 0 ] ;
2025-03-02 01:51:09 +01:00
input = new Uint8Array ( input ) ;
2025-03-02 01:41:12 +01:00
switch ( algorithm ) {
2025-03-03 17:15:26 +01:00
case "Custom" : return this . custom ( args [ 1 ] , input , args [ 2 ] , args [ 3 ] , args [ 4 ] , args [ 5 ] , args [ 6 ] ) ;
2025-03-02 01:41:12 +01:00
case "CRC-3/GSM" : return this . crc ( 3 n , input , 0x3 n , 0x0 n , false , false , 0x7 n ) ;
case "CRC-3/ROHC" : return this . crc ( 3 n , input , 0x3 n , 0x7 n , true , true , 0x0 n ) ;
case "CRC-4/G-704" : return this . crc ( 4 n , input , 0x3 n , 0x0 n , true , true , 0x0 n ) ;
case "CRC-4/INTERLAKEN" : return this . crc ( 4 n , input , 0x3 n , 0xF n , false , false , 0xF n ) ;
case "CRC-4/ITU" : return this . crc ( 4 n , input , 0x3 n , 0x0 n , true , true , 0x0 n ) ;
case "CRC-5/EPC" : return this . crc ( 5 n , input , 0x09 n , 0x09 n , false , false , 0x00 n ) ;
case "CRC-5/EPC-C1G2" : return this . crc ( 5 n , input , 0x09 n , 0x09 n , false , false , 0x00 n ) ;
case "CRC-5/G-704" : return this . crc ( 5 n , input , 0x15 n , 0x00 n , true , true , 0x00 n ) ;
case "CRC-5/ITU" : return this . crc ( 5 n , input , 0x15 n , 0x00 n , true , true , 0x00 n ) ;
case "CRC-5/USB" : return this . crc ( 5 n , input , 0x05 n , 0x1F n , true , true , 0x1F n ) ;
case "CRC-6/CDMA2000-A" : return this . crc ( 6 n , input , 0x27 n , 0x3F n , false , false , 0x00 n ) ;
case "CRC-6/CDMA2000-B" : return this . crc ( 6 n , input , 0x07 n , 0x3F n , false , false , 0x00 n ) ;
case "CRC-6/DARC" : return this . crc ( 6 n , input , 0x19 n , 0x00 n , true , true , 0x00 n ) ;
case "CRC-6/G-704" : return this . crc ( 6 n , input , 0x03 n , 0x00 n , true , true , 0x00 n ) ;
case "CRC-6/GSM" : return this . crc ( 6 n , input , 0x2F n , 0x00 n , false , false , 0x3F n ) ;
case "CRC-6/ITU" : return this . crc ( 6 n , input , 0x03 n , 0x00 n , true , true , 0x00 n ) ;
case "CRC-7/MMC" : return this . crc ( 7 n , input , 0x09 n , 0x00 n , false , false , 0x00 n ) ;
case "CRC-7/ROHC" : return this . crc ( 7 n , input , 0x4F n , 0x7F n , true , true , 0x00 n ) ;
case "CRC-7/UMTS" : return this . crc ( 7 n , input , 0x45 n , 0x00 n , false , false , 0x00 n ) ;
case "CRC-8" : return this . crc ( 8 n , input , 0x07 n , 0x00 n , false , false , 0x00 n ) ;
case "CRC-8/8H2F" : return this . crc ( 8 n , input , 0x2F n , 0xFF n , false , false , 0xFF n ) ;
case "CRC-8/AES" : return this . crc ( 8 n , input , 0x1D n , 0xFF n , true , true , 0x00 n ) ;
case "CRC-8/AUTOSAR" : return this . crc ( 8 n , input , 0x2F n , 0xFF n , false , false , 0xFF n ) ;
case "CRC-8/BLUETOOTH" : return this . crc ( 8 n , input , 0xA7 n , 0x00 n , true , true , 0x00 n ) ;
case "CRC-8/CDMA2000" : return this . crc ( 8 n , input , 0x9B n , 0xFF n , false , false , 0x00 n ) ;
case "CRC-8/DARC" : return this . crc ( 8 n , input , 0x39 n , 0x00 n , true , true , 0x00 n ) ;
case "CRC-8/DVB-S2" : return this . crc ( 8 n , input , 0xD5 n , 0x00 n , false , false , 0x00 n ) ;
case "CRC-8/EBU" : return this . crc ( 8 n , input , 0x1D n , 0xFF n , true , true , 0x00 n ) ;
case "CRC-8/GSM-A" : return this . crc ( 8 n , input , 0x1D n , 0x00 n , false , false , 0x00 n ) ;
case "CRC-8/GSM-B" : return this . crc ( 8 n , input , 0x49 n , 0x00 n , false , false , 0xFF n ) ;
case "CRC-8/HITAG" : return this . crc ( 8 n , input , 0x1D n , 0xFF n , false , false , 0x00 n ) ;
case "CRC-8/I-432-1" : return this . crc ( 8 n , input , 0x07 n , 0x00 n , false , false , 0x55 n ) ;
case "CRC-8/I-CODE" : return this . crc ( 8 n , input , 0x1D n , 0xFD n , false , false , 0x00 n ) ;
case "CRC-8/ITU" : return this . crc ( 8 n , input , 0x07 n , 0x00 n , false , false , 0x55 n ) ;
case "CRC-8/LTE" : return this . crc ( 8 n , input , 0x9B n , 0x00 n , false , false , 0x00 n ) ;
case "CRC-8/MAXIM" : return this . crc ( 8 n , input , 0x31 n , 0x00 n , true , true , 0x00 n ) ;
case "CRC-8/MAXIM-DOW" : return this . crc ( 8 n , input , 0x31 n , 0x00 n , true , true , 0x00 n ) ;
case "CRC-8/MIFARE-MAD" : return this . crc ( 8 n , input , 0x1D n , 0xC7 n , false , false , 0x00 n ) ;
case "CRC-8/NRSC-5" : return this . crc ( 8 n , input , 0x31 n , 0xFF n , false , false , 0x00 n ) ;
case "CRC-8/OPENSAFETY" : return this . crc ( 8 n , input , 0x2F n , 0x00 n , false , false , 0x00 n ) ;
case "CRC-8/ROHC" : return this . crc ( 8 n , input , 0x07 n , 0xFF n , true , true , 0x00 n ) ;
case "CRC-8/SAE-J1850" : return this . crc ( 8 n , input , 0x1D n , 0xFF n , false , false , 0xFF n ) ;
case "CRC-8/SAE-J1850-ZERO" : return this . crc ( 8 n , input , 0x1D n , 0x00 n , false , false , 0x00 n ) ;
case "CRC-8/SMBUS" : return this . crc ( 8 n , input , 0x07 n , 0x00 n , false , false , 0x00 n ) ;
case "CRC-8/TECH-3250" : return this . crc ( 8 n , input , 0x1D n , 0xFF n , true , true , 0x00 n ) ;
case "CRC-8/WCDMA" : return this . crc ( 8 n , input , 0x9B n , 0x00 n , true , true , 0x00 n ) ;
case "CRC-10/ATM" : return this . crc ( 10 n , input , 0x233 n , 0x000 n , false , false , 0x000 n ) ;
case "CRC-10/CDMA2000" : return this . crc ( 10 n , input , 0x3D9 n , 0x3FF n , false , false , 0x000 n ) ;
case "CRC-10/GSM" : return this . crc ( 10 n , input , 0x175 n , 0x000 n , false , false , 0x3FF n ) ;
case "CRC-10/I-610" : return this . crc ( 10 n , input , 0x233 n , 0x000 n , false , false , 0x000 n ) ;
case "CRC-11/FLEXRAY" : return this . crc ( 11 n , input , 0x385 n , 0x01A n , false , false , 0x000 n ) ;
case "CRC-11/UMTS" : return this . crc ( 11 n , input , 0x307 n , 0x000 n , false , false , 0x000 n ) ;
case "CRC-12/3GPP" : return this . crc ( 12 n , input , 0x80F n , 0x000 n , false , true , 0x000 n ) ;
case "CRC-12/CDMA2000" : return this . crc ( 12 n , input , 0xF13 n , 0xFFF n , false , false , 0x000 n ) ;
case "CRC-12/DECT" : return this . crc ( 12 n , input , 0x80F n , 0x000 n , false , false , 0x000 n ) ;
case "CRC-12/GSM" : return this . crc ( 12 n , input , 0xD31 n , 0x000 n , false , false , 0xFFF n ) ;
case "CRC-12/UMTS" : return this . crc ( 12 n , input , 0x80F n , 0x000 n , false , true , 0x000 n ) ;
case "CRC-13/BBC" : return this . crc ( 13 n , input , 0x1CF5 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-14/DARC" : return this . crc ( 14 n , input , 0x0805 n , 0x0000 n , true , true , 0x0000 n ) ;
case "CRC-14/GSM" : return this . crc ( 14 n , input , 0x202D n , 0x0000 n , false , false , 0x3FFF n ) ;
case "CRC-15/CAN" : return this . crc ( 15 n , input , 0x4599 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-15/MPT1327" : return this . crc ( 15 n , input , 0x6815 n , 0x0000 n , false , false , 0x0001 n ) ;
case "CRC-16" : return this . crc ( 16 n , input , 0x8005 n , 0x0000 n , true , true , 0x0000 n ) ;
case "CRC-16/A" : return this . crc ( 16 n , input , 0x1021 n , 0xC6C6 n , true , true , 0x0000 n ) ;
case "CRC-16/ACORN" : return this . crc ( 16 n , input , 0x1021 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/ARC" : return this . crc ( 16 n , input , 0x8005 n , 0x0000 n , true , true , 0x0000 n ) ;
case "CRC-16/AUG-CCITT" : return this . crc ( 16 n , input , 0x1021 n , 0x1D0F n , false , false , 0x0000 n ) ;
case "CRC-16/AUTOSAR" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , false , false , 0x0000 n ) ;
case "CRC-16/B" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , true , true , 0xFFFF n ) ;
case "CRC-16/BLUETOOTH" : return this . crc ( 16 n , input , 0x1021 n , 0x0000 n , true , true , 0x0000 n ) ;
case "CRC-16/BUYPASS" : return this . crc ( 16 n , input , 0x8005 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/CCITT" : return this . crc ( 16 n , input , 0x1021 n , 0x0000 n , true , true , 0x0000 n ) ;
case "CRC-16/CCITT-FALSE" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , false , false , 0x0000 n ) ;
case "CRC-16/CCITT-TRUE" : return this . crc ( 16 n , input , 0x1021 n , 0x0000 n , true , true , 0x0000 n ) ;
case "CRC-16/CCITT-ZERO" : return this . crc ( 16 n , input , 0x1021 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/CDMA2000" : return this . crc ( 16 n , input , 0xC867 n , 0xFFFF n , false , false , 0x0000 n ) ;
case "CRC-16/CMS" : return this . crc ( 16 n , input , 0x8005 n , 0xFFFF n , false , false , 0x0000 n ) ;
case "CRC-16/DARC" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , false , false , 0xFFFF n ) ;
case "CRC-16/DDS-110" : return this . crc ( 16 n , input , 0x8005 n , 0x800D n , false , false , 0x0000 n ) ;
case "CRC-16/DECT-R" : return this . crc ( 16 n , input , 0x0589 n , 0x0000 n , false , false , 0x0001 n ) ;
case "CRC-16/DECT-X" : return this . crc ( 16 n , input , 0x0589 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/DNP" : return this . crc ( 16 n , input , 0x3D65 n , 0x0000 n , true , true , 0xFFFF n ) ;
case "CRC-16/EN-13757" : return this . crc ( 16 n , input , 0x3D65 n , 0x0000 n , false , false , 0xFFFF n ) ;
case "CRC-16/EPC" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , false , false , 0xFFFF n ) ;
case "CRC-16/EPC-C1G2" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , false , false , 0xFFFF n ) ;
case "CRC-16/GENIBUS" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , false , false , 0xFFFF n ) ;
case "CRC-16/GSM" : return this . crc ( 16 n , input , 0x1021 n , 0x0000 n , false , false , 0xFFFF n ) ;
case "CRC-16/I-CODE" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , false , false , 0xFFFF n ) ;
case "CRC-16/IBM" : return this . crc ( 16 n , input , 0x8005 n , 0x0000 n , true , true , 0x0000 n ) ;
case "CRC-16/IBM-3740" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , false , false , 0x0000 n ) ;
case "CRC-16/IBM-SDLC" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , true , true , 0xFFFF n ) ;
case "CRC-16/IEC-61158-2" : return this . crc ( 16 n , input , 0x1DCF n , 0xFFFF n , false , false , 0xFFFF n ) ;
case "CRC-16/ISO-HDLC" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , true , true , 0xFFFF n ) ;
case "CRC-16/ISO-IEC-14443-3-A" : return this . crc ( 16 n , input , 0x1021 n , 0xC6C6 n , true , true , 0x0000 n ) ;
case "CRC-16/ISO-IEC-14443-3-B" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , true , true , 0xFFFF n ) ;
case "CRC-16/KERMIT" : return this . crc ( 16 n , input , 0x1021 n , 0x0000 n , true , true , 0x0000 n ) ;
case "CRC-16/LHA" : return this . crc ( 16 n , input , 0x8005 n , 0x0000 n , true , true , 0x0000 n ) ;
case "CRC-16/LJ1200" : return this . crc ( 16 n , input , 0x6F63 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/LTE" : return this . crc ( 16 n , input , 0x1021 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/M17" : return this . crc ( 16 n , input , 0x5935 n , 0xFFFF n , false , false , 0x0000 n ) ;
case "CRC-16/MAXIM" : return this . crc ( 16 n , input , 0x8005 n , 0x0000 n , true , true , 0xFFFF n ) ;
case "CRC-16/MAXIM-DOW" : return this . crc ( 16 n , input , 0x8005 n , 0x0000 n , true , true , 0xFFFF n ) ;
case "CRC-16/MCRF4XX" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , true , true , 0x0000 n ) ;
case "CRC-16/MODBUS" : return this . crc ( 16 n , input , 0x8005 n , 0xFFFF n , true , true , 0x0000 n ) ;
case "CRC-16/NRSC-5" : return this . crc ( 16 n , input , 0x080B n , 0xFFFF n , true , true , 0x0000 n ) ;
case "CRC-16/OPENSAFETY-A" : return this . crc ( 16 n , input , 0x5935 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/OPENSAFETY-B" : return this . crc ( 16 n , input , 0x755B n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/PROFIBUS" : return this . crc ( 16 n , input , 0x1DCF n , 0xFFFF n , false , false , 0xFFFF n ) ;
case "CRC-16/RIELLO" : return this . crc ( 16 n , input , 0x1021 n , 0xB2AA n , true , true , 0x0000 n ) ;
case "CRC-16/SPI-FUJITSU" : return this . crc ( 16 n , input , 0x1021 n , 0x1D0F n , false , false , 0x0000 n ) ;
case "CRC-16/T10-DIF" : return this . crc ( 16 n , input , 0x8BB7 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/TELEDISK" : return this . crc ( 16 n , input , 0xA097 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/TMS37157" : return this . crc ( 16 n , input , 0x1021 n , 0x89EC n , true , true , 0x0000 n ) ;
case "CRC-16/UMTS" : return this . crc ( 16 n , input , 0x8005 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/USB" : return this . crc ( 16 n , input , 0x8005 n , 0xFFFF n , true , true , 0xFFFF n ) ;
case "CRC-16/V-41-LSB" : return this . crc ( 16 n , input , 0x1021 n , 0x0000 n , true , true , 0x0000 n ) ;
case "CRC-16/V-41-MSB" : return this . crc ( 16 n , input , 0x1021 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/VERIFONE" : return this . crc ( 16 n , input , 0x8005 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/X-25" : return this . crc ( 16 n , input , 0x1021 n , 0xFFFF n , true , true , 0xFFFF n ) ;
case "CRC-16/XMODEM" : return this . crc ( 16 n , input , 0x1021 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-16/ZMODEM" : return this . crc ( 16 n , input , 0x1021 n , 0x0000 n , false , false , 0x0000 n ) ;
case "CRC-17/CAN-FD" : return this . crc ( 17 n , input , 0x1685B n , 0x00000 n , false , false , 0x00000 n ) ;
case "CRC-21/CAN-FD" : return this . crc ( 21 n , input , 0x102899 n , 0x000000 n , false , false , 0x000000 n ) ;
case "CRC-24/BLE" : return this . crc ( 24 n , input , 0x00065B n , 0x555555 n , true , true , 0x000000 n ) ;
case "CRC-24/FLEXRAY-A" : return this . crc ( 24 n , input , 0x5D6DCB n , 0xFEDCBA n , false , false , 0x000000 n ) ;
case "CRC-24/FLEXRAY-B" : return this . crc ( 24 n , input , 0x5D6DCB n , 0xABCDEF n , false , false , 0x000000 n ) ;
case "CRC-24/INTERLAKEN" : return this . crc ( 24 n , input , 0x328B63 n , 0xFFFFFF n , false , false , 0xFFFFFF n ) ;
case "CRC-24/LTE-A" : return this . crc ( 24 n , input , 0x864CFB n , 0x000000 n , false , false , 0x000000 n ) ;
case "CRC-24/LTE-B" : return this . crc ( 24 n , input , 0x800063 n , 0x000000 n , false , false , 0x000000 n ) ;
case "CRC-24/OPENPGP" : return this . crc ( 24 n , input , 0x864CFB n , 0xB704CE n , false , false , 0x000000 n ) ;
case "CRC-24/OS-9" : return this . crc ( 24 n , input , 0x800063 n , 0xFFFFFF n , false , false , 0xFFFFFF n ) ;
case "CRC-30/CDMA" : return this . crc ( 30 n , input , 0x2030B9C7 n , 0x3FFFFFFF n , false , false , 0x3FFFFFFF n ) ;
case "CRC-31/PHILIPS" : return this . crc ( 31 n , input , 0x04C11DB7 n , 0x7FFFFFFF n , false , false , 0x7FFFFFFF n ) ;
case "CRC-32" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/AAL5" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0xFFFFFFFF n , false , false , 0xFFFFFFFF n ) ;
case "CRC-32/ADCCP" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/AIXM" : return this . crc ( 32 n , input , 0x814141AB n , 0x00000000 n , false , false , 0x00000000 n ) ;
case "CRC-32/AUTOSAR" : return this . crc ( 32 n , input , 0xF4ACFB13 n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/BASE91-C" : return this . crc ( 32 n , input , 0x1EDC6F41 n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/BASE91-D" : return this . crc ( 32 n , input , 0xA833982B n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/BZIP2" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0xFFFFFFFF n , false , false , 0xFFFFFFFF n ) ;
case "CRC-32/C" : return this . crc ( 32 n , input , 0x1EDC6F41 n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/CASTAGNOLI" : return this . crc ( 32 n , input , 0x1EDC6F41 n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/CD-ROM-EDC" : return this . crc ( 32 n , input , 0x8001801B n , 0x00000000 n , true , true , 0x00000000 n ) ;
case "CRC-32/CKSUM" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0x00000000 n , false , false , 0xFFFFFFFF n ) ;
case "CRC-32/D" : return this . crc ( 32 n , input , 0xA833982B n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/DECT-B" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0xFFFFFFFF n , false , false , 0xFFFFFFFF n ) ;
case "CRC-32/INTERLAKEN" : return this . crc ( 32 n , input , 0x1EDC6F41 n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/ISCSI" : return this . crc ( 32 n , input , 0x1EDC6F41 n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/ISO-HDLC" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/JAMCRC" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0xFFFFFFFF n , true , true , 0x00000000 n ) ;
case "CRC-32/MEF" : return this . crc ( 32 n , input , 0x741B8CD7 n , 0xFFFFFFFF n , true , true , 0x00000000 n ) ;
case "CRC-32/MPEG-2" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0xFFFFFFFF n , false , false , 0x00000000 n ) ;
case "CRC-32/NVME" : return this . crc ( 32 n , input , 0x1EDC6F41 n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/PKZIP" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/POSIX" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0x00000000 n , false , false , 0xFFFFFFFF n ) ;
case "CRC-32/Q" : return this . crc ( 32 n , input , 0x814141AB n , 0x00000000 n , false , false , 0x00000000 n ) ;
case "CRC-32/SATA" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0x52325032 n , false , false , 0x00000000 n ) ;
case "CRC-32/V-42" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-32/XFER" : return this . crc ( 32 n , input , 0x000000AF n , 0x00000000 n , false , false , 0x00000000 n ) ;
case "CRC-32/XZ" : return this . crc ( 32 n , input , 0x04C11DB7 n , 0xFFFFFFFF n , true , true , 0xFFFFFFFF n ) ;
case "CRC-40/GSM" : return this . crc ( 40 n , input , 0x0004820009 n , 0x0000000000 n , false , false , 0xFFFFFFFFFF n ) ;
case "CRC-64/ECMA-182" : return this . crc ( 64 n , input , 0x42F0E1EBA9EA3693 n , 0x0000000000000000 n , false , false , 0x0000000000000000 n ) ;
case "CRC-64/GO-ECMA" : return this . crc ( 64 n , input , 0x42F0E1EBA9EA3693 n , 0xFFFFFFFFFFFFFFFF n , true , true , 0xFFFFFFFFFFFFFFFF n ) ;
case "CRC-64/GO-ISO" : return this . crc ( 64 n , input , 0x000000000000001B n , 0xFFFFFFFFFFFFFFFF n , true , true , 0xFFFFFFFFFFFFFFFF n ) ;
case "CRC-64/MS" : return this . crc ( 64 n , input , 0x259C84CBA6426349 n , 0xFFFFFFFFFFFFFFFF n , true , true , 0x0000000000000000 n ) ;
case "CRC-64/NVME" : return this . crc ( 64 n , input , 0xAD93D23594C93659 n , 0xFFFFFFFFFFFFFFFF n , true , true , 0xFFFFFFFFFFFFFFFF n ) ;
case "CRC-64/REDIS" : return this . crc ( 64 n , input , 0xAD93D23594C935A9 n , 0x0000000000000000 n , true , true , 0x0000000000000000 n ) ;
case "CRC-64/WE" : return this . crc ( 64 n , input , 0x42F0E1EBA9EA3693 n , 0xFFFFFFFFFFFFFFFF n , false , false , 0xFFFFFFFFFFFFFFFF n ) ;
case "CRC-64/XZ" : return this . crc ( 64 n , input , 0x42F0E1EBA9EA3693 n , 0xFFFFFFFFFFFFFFFF n , true , true , 0xFFFFFFFFFFFFFFFF n ) ;
case "CRC-82/DARC" : return this . crc ( 82 n , input , 0x0308C0111011401440411 n , 0x000000000000000000000 n , true , true , 0x000000000000000000000 n ) ;
default : throw new OperationError ( "Unknown checksum algorithm" ) ;
}
}
}
export default CRCChecksum ;