Constructors

  • Creates an instance of the CRC (Cyclic Redundancy Check) class.

    Parameters

    • name: string

      The name of the CRC algorithm.

    • width: number

      The width of the CRC in bits.

    • polynomial: number

      The polynomial used for the CRC calculation.

    • initial: number

      The initial value for the CRC calculation.

    • finalXor: number

      The value to XOR with the final CRC value.

    • inputReflected: boolean

      Whether the input bytes should be reflected.

    • resultReflected: boolean

      Whether the result should be reflected.

    Returns CRC

Accessors

  • get finalXor(): number
  • Returns number

  • set finalXor(v: number): void
  • Parameters

    • v: number

    Returns void

  • get initial(): number
  • Returns number

  • set initial(v: number): void
  • Parameters

    • v: number

    Returns void

  • get inputReflected(): boolean
  • Returns boolean

  • set inputReflected(v: boolean): void
  • Parameters

    • v: boolean

    Returns void

  • get name(): string
  • Returns string

  • set name(v: string): void
  • Parameters

    • v: string

    Returns void

  • get polynomial(): number
  • Returns number

  • set polynomial(v: number): void
  • Parameters

    • v: number

    Returns void

  • get resultReflected(): boolean
  • Returns boolean

  • set resultReflected(v: boolean): void
  • Parameters

    • v: boolean

    Returns void

  • get table(): number[]
  • Returns number[]

  • get width(): number
  • Returns number

  • set width(v: number): void
  • Parameters

    • v: number

    Returns void

  • get defaults(): CRC[]
  • Returns a list of default CRC configurations.

    The list includes various CRC algorithms with their respective parameters:

    • Name: The name of the CRC algorithm.
    • Width: The width of the CRC (number of bits).
    • Polynomial: The polynomial used for the CRC calculation.
    • Initial Value: The initial value for the CRC calculation.
    • Final XOR Value: The value to XOR with the final CRC value.
    • Reflect Input: Whether to reflect the input bytes.
    • Reflect Output: Whether to reflect the output CRC value.

    Returns CRC[]

    An array of CRC configurations.

Methods

  • Computes the CRC (Cyclic Redundancy Check) value for the given input bytes.

    Parameters

    • bytes: number[] | Buffer

      The input data as an array of numbers or a Buffer.

    Returns number

    • The computed CRC value.
  • Parameters

    • bytes: number[] | Buffer

    Returns Buffer

  • Retrieves a CRC object from the defaults list by its name.

    Parameters

    • name: string

      The name of the CRC object to find.

    Returns undefined | CRC

    The CRC object with the specified name, or undefined if not found.