crc32
Compute the CRC32 checksum of a byte buffer.
function crc32(data, previous?): number;
Defined in: src/utils/aws/crc32.ts:56
Compute the CRC32 checksum of a byte buffer.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
data | Uint8Array | undefined | The bytes to checksum. |
previous | number | 0 | Optional running CRC from a previous call, for incremental computation over concatenated buffers. |
Returns
number
The unsigned 32-bit CRC32 value.
Remarks
Uses the IEEE 802.3 (zlib) polynomial in its reflected form. The result is an unsigned 32-bit integer, matching the value AWS event-stream messages carry in their prelude CRC and message CRC fields.
Example
import { crc32 } from 'composite-voice/utils';
crc32(new TextEncoder().encode('hello')); // 0x3610a686