MCPcopy Index your code
hub / github.com/cotag/ts-md5

github.com/cotag/ts-md5 @v2.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.0.1 ↗ · + Follow
35 symbols 75 edges 9 files 10 documented · 29% 10 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
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:


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.


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

Extension points exported contracts — how you extend this code

HashingResponse (Interface)
(no doc)
src/md5_file_hasher.ts
WorkerOptions (Interface)
(no doc)
src/parallel_hasher.ts
HasherState (Interface)
(no doc)
src/md5.ts
HashingRequest (Interface)
(no doc)
src/parallel_hasher.ts

Core symbols most depended-on inside this repo

appendByteArray
called by 16
src/md5.ts
appendStr
called by 15
src/md5.ts
end
called by 15
src/md5.ts
start
called by 8
src/md5.ts
hashStr
called by 7
src/md5.ts
_md5cycle
called by 5
src/md5.ts
hash
called by 4
src/md5_file_hasher.ts
_processPart
called by 2
src/md5_file_hasher.ts

Shape

Method 23
Class 6
Interface 4
Function 2

Languages

TypeScript100%

Modules by API surface

src/md5.ts15 symbols
src/parallel_hasher.ts9 symbols
src/md5_file_hasher.ts9 symbols
test/md5.spec.ts1 symbols
build-worker.js1 symbols

For agents

$ claude mcp add ts-md5 \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page