Release Archive Tools 0.2.0
Verify / verify (push) Canceled after 0s

This commit is contained in:
2026-09-02 09:34:59 +02:00
parent a49ec6b17a
commit fe578f46bd
47 changed files with 3337 additions and 253 deletions
+8 -16
View File
@@ -1,25 +1,17 @@
const table = (() => {
const values = new Uint32Array(256);
for (let index = 0; index < values.length; index += 1) {
let value = index;
for (let bit = 0; bit < 8; bit += 1)
value = value & 1 ? 0xedb88320 ^ (value >>> 1) : value >>> 1;
values[index] = value >>> 0;
}
return values;
})();
import {
crc32 as sharedCrc32,
formatChecksum,
} from "@add-ideas/toolbox-helpers";
import { ARCHIVE_LIMITS } from "./limits";
export function crc32(bytes: Uint8Array): number {
let value = 0xffffffff;
for (const byte of bytes)
value = table[(value ^ byte) & 0xff]! ^ (value >>> 8);
return (value ^ 0xffffffff) >>> 0;
return sharedCrc32(bytes, ARCHIVE_LIMITS.maxExpandedBytes);
}
export function crc32Hex(bytes: Uint8Array): string {
return crc32(bytes).toString(16).padStart(8, "0");
return formatChecksum(crc32(bytes));
}
export function uint32Hex(value: number): string {
return (value >>> 0).toString(16).padStart(8, "0");
return formatChecksum(value >>> 0);
}