js-md5
A fast, dependency-free MD5 hash function for JavaScript with UTF-8 support
Repository Health
Technical Analysis
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 incrementalmd5.create()/update()/hex()streaming API - Built-in HMAC-MD5 support via
md5.hmac()andmd5.hmac.create() - Support for string, byte
Array,Uint8Array, andArrayBufferinputs 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.
Used by 3 apps in this directory
GraphQL Hive
Developer Tools · Devops · Monitoring
Open-source GraphQL schema registry and observability platform with breaking change detection, federation support, and CI/CD integration for teams of any size.
Hoppscotch
Developer Tools
A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.
Jitsi Meet
Team Chat · Collaboration · Video Conferencing
Open-source, end-to-end encrypted video conferencing you can self-host or embed into any web or mobile app.