ts-md5
A TypeScript MD5 implementation with incremental, file, and web-worker hashing
Repository Health
Technical Analysis
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
Md5class with statichashStr/hashAsciiStrhelpers and chainableappendStr/appendAsciiStr/appendByteArraymethods for incremental hashing - Unicode-safe string hashing that correctly handles multi-byte characters
- A
ParallelHasherclass 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.
Used by 3 apps in this directory
APITable
Low Code Platforms · Databases
API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.
LibreChat
Developer Tools · AI Assistants
Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.
LobeHub
AI Assistants · Productivity · Automation
Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.