# ts-md5

> TypeScript MD5 implementation

Latest version **2.0.1** (published 2025-07-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install ts-md5
pnpm add ts-md5
yarn add ts-md5
bun add ts-md5
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2025-07-02 |
| First published | 2016-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 186.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 172 |
| Maintainers | stakach, yuion |
| Keywords | placeos, cotag, md5, typescript, ts |

## Links

- npm: https://www.npmjs.com/package/ts-md5
- Repository: https://github.com/cotag/ts-md5
- Issues: https://github.com/cotag/ts-md5/issues
- npm.io page: https://npm.io/package/ts-md5

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 2.0.1 (latest) — 2025-07-02
- 2.0.0 — 2025-07-02
- 1.3.1 — 2022-08-16
- 1.3.0 — 2022-08-16
- 1.2.11 — 2022-01-23
- 1.2.10 — 2021-11-16
- 1.2.9 — 2021-06-22
- 1.2.8 — 2021-05-21
- 1.2.7 — 2019-10-22
- 1.2.6 — 2019-09-09
- 1.2.5 — 2019-08-30
- 1.2.4 — 2018-01-29
- 1.2.3 — 2018-01-15
- 1.2.2 — 2017-08-03
- 1.2.1 — 2017-08-03
- … 3 more at https://npm.io/package/ts-md5/versions

## README

# Introduction

A MD5 implementation for TypeScript

* Can handle Unicode strings
* Supports incremental hashing
* Works with Files and Blobs

This library also includes tools for:

* Hashing a file or blob
* A webworker for performing hashing
* A webworker handler for requesting files or blobs to be hashed
     * promise based
     * files or blobs are queued for processing on the webworker


Based on work by

* Joseph Myers: http://www.myersdaily.org/joseph/javascript/md5-text.html
* André Cruz: https://github.com/satazor/SparkMD5
* Raymond Hill: https://github.com/gorhill/yamd5.js


## Usage

### Install

Install the node module with `npm install ts-md5`

### Basic Hashing

1. Import the class
     * `import {Md5} from 'ts-md5';`
2. Hash some things
     * `Md5.hashStr('blah blah blah')` => hex:string
     * `Md5.hashStr('blah blah blah', true)` => raw:Int32Array(4)
     * `Md5.hashAsciiStr('blah blah blah')` => hex:string
     * `Md5.hashAsciiStr('blah blah blah', true)` => raw:Int32Array(4)

For more complex uses:

```typescript

md5 = new Md5();

// Append incrementally your file or other input
// Methods are chainable
md5.appendStr('somestring')
    .appendAsciiStr('a different string')
    .appendByteArray(blob);

// Generate the MD5 hex string
md5.end();

```


### Hashing a File

NOTE:: You have to make sure `ts-md5/dist/md5_worker.js` is made available in your build so it can be accessed directly by a browser
It should always remain as a seperate file.

```typescript

import {ParallelHasher} from 'ts-md5';

let hasher = new ParallelHasher('/path/to/ts-md5/dist/md5_worker.js');
hasher.hash(fileBlob).then(function(result) {
   console.log('md5 of fileBlob is', result);
});

```


## Building from source

## Scripts

1. Build Script: `npm run build`
2. Test Script: `npm run test`


## Publishing

1. Sign up to https://www.npmjs.com/
2. Configure `package.json` https://docs.npmjs.com/files/package.json
3. run `npm publish` https://docs.npmjs.com/cli/publish

# License

MIT

---
_Source: https://npm.io/package/ts-md5 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
