Skip to content

v0.5.3

Latest

Choose a tag to compare

@bddjr bddjr released this 13 Sep 14:20
e5c22a8

926 Bytes (-17)

⚡ Performance & TurboFan JIT Optimization

  • Native ROR Recognition: Migrated bit rotation from ROL to ROR (>>> cnt | a << 32 - cnt) with updated shift string table "94/*;72,<50):61+". This allows V8 TurboFan to natively recognize the rotation pattern and emit a single x86 rorl instruction instead of multiple shift/or instructions.
  • Loop-Invariant Register Hoisting (mul & add): Hoisted round multiplier and adder calculations (let mul = 0x7351 >> l, add = 0x0510 >> l) directly into the inner for header. This eliminates 4 shift instructions and memory loads per step in the hot loop, ensuring optimal register allocation and yielding an immediate speedup.
  • Inlined Endianness Check (reverseOnBE): Inlined the isBE check directly into reverseOnBE (a => isBE ? a.reverse() : a) instead of writing isBE && before every call site, enabling cleaner expression nesting and saving code size.

🧩 Expanded Input Types

  • Added official support for Int8Array and number[] inputs in both MD5 and HMAC-MD5 (elements are safely cast to bytes via Uint8Array).
  • Updated TypeScript declarations (main.d.ts), JSDoc (@typedef Input), and README.md with usage examples.

🛠️ Tooling & Dependencies

  • Updated terser to ^5.51.2 and es-check to ^9.7.1.
  • Added tsconfig.nocheck.json composite project reference for minified files.
  • Added comprehensive test cases for Int8Array and number[] in scripts/test.mjs.
  • Added to CDNJS (cdnjs/packages#2199).

📊 Benchmark

> pnpm benchmark
$ node scripts/benchmark.mjs && node scripts/test-513MiB.mjs
Data length: 104857600 chars (100MiB)
--------------------------------------------------
tinyhmacmd5     : 374.04 ms
spark-md5       : 513.18 ms
js-md5          : 481.65 ms
crypto-js       : 1667.43 ms
blueimp-md5     : 3753.25 ms
node:crypto     : 130.88 ms
--------------------------------------------------
✅ All pure JS implementations match node:crypto result.

--- Pure 513MiB Test (No prior small tests) ---
tinyhmacmd5 HMAC-MD5 timer: 1.794s
node:crypto HMAC-MD5 timer: 550.872ms
tinyhmacmd5 MD5 timer: 1.786s
node:crypto MD5 timer: 548.873ms

CPU: i5-10600KF
DRAM: 64GiB DDR4 3333MT/s
OS: Windows 11 Pro for Workstations 25H2 26200.8737
Node.js: v26.8.1

Full Changelog: v0.5.2...v0.5.3