/** * CRC32 calculation utility for ZIP files * * - Node.js: Uses native zlib.crc32 (C++ implementation, ~100x faster) * - Browser: Uses lookup table optimization * * The polynomial used is the standard CRC-32 IEEE 802.3: * x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1 * Represented as 0xEDB88320 in reversed (LSB-first) form */ import { crc32Finalize } from "./crc32.base.js"; /** * Synchronously ensure zlib is loaded for Node.js. * Used by the sync deflate path where the async dynamic import may not have * resolved yet. Falls back to `require()` which is synchronous in Node.js. */ export declare function ensureZlibSync(): void; /** * Calculate CRC32 checksum for the given data * Uses native zlib.crc32 in Node.js for ~100x better performance * * @param data - Input data as Uint8Array or Buffer * @returns CRC32 checksum as unsigned 32-bit integer * * @example * ```ts * const data = new TextEncoder().encode("Hello, World!"); * const checksum = crc32(data); * console.log(checksum.toString(16)); // "ec4ac3d0" * ``` */ export declare function crc32(data: Uint8Array): number; /** * Ensure zlib is loaded (for use before calling crc32) */ export declare function ensureCrc32(): Promise; /** * Calculate CRC32 incrementally (useful for streaming) * Call with initial crc of 0xffffffff, then finalize with crc32Finalize * In Node.js, this uses native zlib.crc32 when available for performance. * The internal CRC state remains the same as the JS table implementation: * - initial state: 0xffffffff * - finalize: xor with 0xffffffff * * @param crc - Current CRC value (start with 0xffffffff) * @param data - Input data chunk * @returns Updated CRC value (not finalized) * * @example * ```ts * let crc = 0xffffffff; * crc = crc32Update(crc, chunk1); * crc = crc32Update(crc, chunk2); * const checksum = crc32Finalize(crc); * ``` */ export declare function crc32Update(crc: number, data: Uint8Array): number; /** * Finalize CRC32 calculation * XOR with 0xffffffff and convert to unsigned 32-bit * * @param crc - CRC value from crc32Update * @returns Final CRC32 checksum */ export { crc32Finalize };