@technobuddha/library
Version:
A large library of useful functions
37 lines (36 loc) • 1.18 kB
TypeScript
import { type BinaryEncoding } from './@types/binary-encoding.ts';
import { type TextEncoding } from './@types/text-encoding.ts';
import { type BinaryObject } from './binary-object.ts';
import { HashBase } from './hash-base.ts';
/**
* Compute the CRC32 checksum of a binary object
* @example
* ```typescript
* const crc = new Crc32();
* crc.update('hello world', 'utf8');
* crc.digest('hex');
* // '0d4a1185'
* ```
* ```typescript
* const crc = new Crc32();
* crc.update(new Uint8Array([0x72,0x69,0x4c,0x4c,0x4f]));
* crc.digest('hex');
* // 'c031d497'
* ```
* @group Binary
* @category Hash
*/
export declare class Crc32 extends HashBase {
private crc;
/**
* Creates a new CRC32 hash instance and initializes its internal state.
* @remarks
* The CRC value is initialized to -1, as required by the CRC32 algorithm specification.
* Use {@link update} to process data and {@link digest} to obtain the final hash value.
*/
constructor();
update(data: BinaryObject | ArrayLike<number>): this;
update(data: string, encoding?: TextEncoding): this;
digest(): Uint8Array;
digest(encoding: BinaryEncoding): string;
}