Package detail

ts-md5

cotag2.1mMIT2.0.1

TypeScript MD5 implementation

placeos, cotag, md5, typescript

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

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

changelog

Changelog

All notable changes to this project will be documented in this file.

[1.3.1] - 2022-08-16

Bug Fixes

Documentation

Build

Deps-dev

  • Bump semantic-release from 17.4.4 to 19.0.3

Ci

[1.3.0] - 2022-08-16

Features

Project

  • Re-structure project to be easy to work with going forward

Build

Deps

  • Bump terser from 4.6.11 to 4.8.1
  • Bump ajv from 6.12.2 to 6.12.6
  • Bump follow-redirects from 1.11.0 to 1.15.1
  • Bump ssri from 6.0.1 to 6.0.2
  • Bump elliptic from 6.5.3 to 6.5.4

Deps-dev

  • Bump karma from 5.0.2 to 6.4.0

[1.2.11] - 2022-01-23

Bug Fixes

[1.2.10] - 2021-11-16

Bug Fixes

Worker

  • Remove require call from worker script

[1.2.9] - 2021-06-22

Bug Fixes

Worker

  • Remove questionable language from md5_worker.js

[1.2.8] - 2021-05-21

Bug Fixes

Package

  • Remove duplicate key in package.json

Parallel-hasher

  • Add WorkerOptions interface for typescript < 3
  • Add updated definition for workers

Features

Build

Deps

  • Bump http-proxy from 1.18.0 to 1.18.1
  • Bump elliptic from 6.5.2 to 6.5.3
  • Bump lodash from 4.17.15 to 4.17.19
  • Bump y18n from 4.0.0 to 5.0.5
  • Bump lodash from 4.17.19 to 4.17.21

Tweak