2.9 KiB
2.9 KiB
Useful JavaScript Utilities
Two tiers of resources in this kit:
- Original, dependency-free reference implementations authored in
09_Collected_JS/— safe to read, adapt, and test offline. - Links to external open-source libraries cataloged (not redistributed) in
02_Resource_Catalog/links.md— review license and runtime compatibility before adapting any code from them into a Multi-PROG host.
Binary parsing
| Utility | Location |
|---|---|
BinaryReader (stateful DataView/Uint8Array reader) |
09_Collected_JS/binary/dataview_helpers.mjs |
parseStruct (declarative struct parser) |
09_Collected_JS/binary/struct_reader.mjs |
| External: binary-parser, restructure, buffer-layout, jBinary | 02_Resource_Catalog/links.md |
Checksums
| Algorithm | Location |
|---|---|
| CRC-8 | 09_Collected_JS/checksums/crc8.mjs |
| CRC-16 (CCITT-FALSE, MODBUS) | 09_Collected_JS/checksums/crc16.mjs, also 03_Script_Starter_Kit/binary_utils.mjs |
| CRC-32, CRC-32C | 09_Collected_JS/checksums/crc32.mjs, also 03_Script_Starter_Kit/binary_utils.mjs |
| CRC-64/XZ | 09_Collected_JS/checksums/crc64.mjs |
| Fletcher-16/32 | 09_Collected_JS/checksums/fletcher.mjs |
| Adler-32 | 09_Collected_JS/checksums/adler32.mjs, also 03_Script_Starter_Kit/binary_utils.mjs |
| External: js-crc, CRC RevEng catalogue (for verification vectors) | 02_Resource_Catalog/links.md |
Encoding
| Encoding | Location |
|---|---|
| Hex | 09_Collected_JS/encoding/hex.mjs, also 03_Script_Starter_Kit/binary_utils.mjs |
| BCD | 09_Collected_JS/encoding/bcd.mjs, also 03_Script_Starter_Kit/binary_utils.mjs |
| ASCII | 09_Collected_JS/encoding/ascii.mjs, also 03_Script_Starter_Kit/binary_utils.mjs |
| UTF-8 | 09_Collected_JS/encoding/utf8.mjs (thin TextEncoder/TextDecoder wrappers) |
Hashing
| Algorithm | Location |
|---|---|
| SHA-1 | 09_Collected_JS/hashing/sha1.mjs |
| SHA-256 | 09_Collected_JS/hashing/sha256.mjs |
| MD5 | 09_Collected_JS/hashing/md5.mjs |
| External: js-sha256, js-sha1, blueimp JavaScript-MD5, crypto-js | 02_Resource_Catalog/links.md |
Cryptography (reference only, not implemented here)
AES/DES symmetric ciphers are intentionally not implemented in this kit (see SCRIPT_DEVELOPMENT_GUIDE.md for the boundary rationale). Use official standards and reference libraries instead: NIST FIPS 197 (AES), OWASP Cryptographic Storage Cheat Sheet, and the crypto-js link — all cataloged in 02_Resource_Catalog/links.md.
Verifying correctness
Every algorithm implemented in 09_Collected_JS/ is checked in 09_Collected_JS/tests/test_vectors.mjs against standard published check values (e.g. CRC32/Adler32/SHA/MD5 of the ASCII strings "123456789" or "abc"). Run it with a local Node.js install:
node 09_Collected_JS/tests/test_vectors.mjs