ts-md5

A TypeScript MD5 implementation with incremental, file, and web-worker hashing

Library
npm
v2.0.1
171stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
41/100Fair
Development Activity4
Maintenance20
Community60
Maturity60
Momentum20

Technical Analysis

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

ts-md5 is a native TypeScript port of the MD5 hashing algorithm, built on prior JavaScript MD5 implementations (SparkMD5, yamd5.js) and extended with Unicode-safe string hashing, incremental/chainable appends, and first-class support for hashing Files and Blobs in the browser. It ships a ParallelHasher helper that offloads file hashing to a web worker so large uploads can be checksummed off the main thread, making it a common choice for browser apps and Angular/TypeScript projects that need client-side MD5 without extra polyfills.

What You Get

  • A typed Md5 class with static hashStr/hashAsciiStr helpers and chainable appendStr/appendAsciiStr/appendByteArray methods for incremental hashing
  • Unicode-safe string hashing that correctly handles multi-byte characters
  • A ParallelHasher class that hashes Files/Blobs inside a bundled web worker (md5_worker.js), returning a Promise
  • Full TypeScript type definitions and both ESM and CJS build outputs

Common Use Cases

  • Computing client-side MD5 checksums of uploaded files before or during transfer to a server
  • Generating cache-busting or content-addressable keys for browser-stored data
  • Hashing form or user input in Angular/TypeScript applications without relying on Node’s crypto module
  • Offloading large file hashing to a web worker to keep the UI thread responsive

Under The Hood

Architecture - The core Md5 class in src/md5.ts (477 lines) implements the MD5 compression function directly (message padding, four rounds of bitwise mixing over 32-bit words) and exposes both static one-shot helpers and a chainable incremental API (appendStr, appendAsciiStr, appendByteArray, end); src/md5_file_hasher.ts (114 lines) adds a ParallelHasher that posts File/Blob chunks to a bundled worker script (src/worker.js, compiled to dist/md5_worker.js by a dedicated build-worker.js step) and resolves a Promise once the worker replies. Tech Stack - Modern TypeScript 5.x toolchain: Vite for building dual ESM/CJS bundles plus type declarations (via vite-plugin-dts), Vitest with @vitest/coverage-v8 for testing, ESLint and Prettier (with prettier-plugin-organize-imports) for style, TypeDoc for generated API docs, and semantic-release for automated versioning/publishing. Code Quality - Two Vitest spec files (test/md5.spec.ts, test/md5_file_hasher.spec.ts) cover the hashing core and the file-hasher/worker path; the package.json also carries a legacy Jest config block left over from an earlier test runner, and coverage tooling is wired in via test:cov, indicating an actively maintained quality gate despite the low commit-frequency signal from GitHub activity stats. API Design - The static Md5.hashStr/hashAsciiStr entry points cover the common case in one call, while the chainable instance methods and ParallelHasher class scale up to incremental and off-thread use cases; full TypeScript types and a documented public README reduce onboarding friction, though the worker-file distribution requirement (ts-md5/dist/md5_worker.js must be served separately) is a manual build/deploy step most competing pure-JS MD5 libraries don’t require.

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