js-md5

A fast, dependency-free MD5 hash function for JavaScript with UTF-8 support

Library
npm
v0.9.2
837stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
62/100Good
Development Activity52
Maintenance40
Community68
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
63/100Good
Architecture60
Code Quality62
Innovation55
Learning Curve75

js-md5 is a lightweight JavaScript implementation of the MD5 hashing algorithm that works identically in Node.js, browsers, and Web Workers. It handles UTF-8 strings, byte arrays, Uint8Array, and ArrayBuffer input natively, and exposes both a simple one-shot function and a streaming create()/update()/hex() API for hashing data incrementally.

Beyond plain MD5, the library ships an HMAC-MD5 implementation (md5.hmac) and multiple output encodings (hex, byte array, base64, ArrayBuffer), making it a drop-in utility for checksums, cache keys, non-cryptographic fingerprinting, and legacy HMAC signing schemes that still require MD5 compatibility.

What You Get

  • A single-call md5() function plus an incremental md5.create() / update() / hex() streaming API
  • Built-in HMAC-MD5 support via md5.hmac() and md5.hmac.create()
  • Support for string, byte Array, Uint8Array, and ArrayBuffer inputs with UTF-8 encoding handled automatically
  • Multiple output formats: hex string, byte array, base64, and ArrayBuffer/Buffer
  • Works across Node.js, browsers, AMD/RequireJS, and Web Worker environments with no external dependencies

Common Use Cases

  • Generating checksums for file integrity or cache-busting keys in build tooling
  • Computing non-cryptographic fingerprints for deduplication or content-addressable storage
  • Interfacing with legacy APIs or protocols that still require MD5 or HMAC-MD5 signatures
  • Hashing large strings or files incrementally in a Web Worker without blocking the UI thread

Under The Hood

Architecture The entire implementation lives in a single UMD-wrapped file, src/md5.js, which detects its runtime (Node.js, browser window, Web Worker self, or AMD loader) at load time via feature checks (typeof process, typeof window, define.amd) and exposes the same md5 namespace regardless of environment. A Md5 constructor implements the standard MD5 block-processing algorithm (start(), update(), finalize()) operating on a shared Uint32Array/ArrayBuffer scratch buffer for performance, with a thin Hmac subclass reusing the same block engine for HMAC-MD5. Tech Stack Zero runtime dependencies; devDependencies are limited to mocha/nyc/expect.js for testing, uglify-js for the minified browser build, and jsdoc for API docs, reflecting the library’s minimal, no-build-step philosophy. Code Quality Tests in tests/node-test.js, tests/hmac-test.js, and tests/worker-test.js cover string/array/UTF-8 inputs, HMAC vectors, and Web Worker execution, run through nyc for coverage; the source favors terse variable names and manual feature-detection branches over modern class syntax, trading some readability for broad legacy-runtime compatibility (down to very old browsers and AMD loaders). API Design The public surface is deliberately small: a callable md5() for one-shot hashing, md5.create() for incremental/streaming use, and md5.hmac mirroring both forms for keyed hashing, with output-format methods (hex(), array(), base64(), arrayBuffer()) attached directly to the resulting instances — very low boilerplate to get a working hash in any JS environment.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search