1.3.1 • Published 3 years ago

ts-md5 v1.3.1

Weekly downloads
88,661
License
MIT
Repository
github
Last release
3 years ago

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 src

The project is written in typescript and transpiled into ES5.

  1. Install TypeScript: npm install -g typescript (if you haven't already)
  2. Configure compile options in tsconfig.json
  3. Perform build using: tsc

You can find more information here: https://github.com/Microsoft/TypeScript/wiki/tsconfig.json

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

zbg-video-react@falchion-studios/claymore-api@ondemandenv.dev/odmd-contracts@sooha/helpergdweb@stratosui/core@piotrowiczmateusz/common-modules@car-test-pp/test-sdk-v1-angular-ui@piotrowiczmateusz/scope-common-modulescharz@swarnavl/one-element-testknockout.bootstrapper@mcgordonite/theia-git@mcgordonite/theia-callhierarchy@fawazorg/wolf.jsbiglelegal@asksuzy/suzylive-sdkgraphxr-api-test4atlas-metrics-servicehbnglib@asksuzy/typescript-sdkts-mvx-foundationamap-basegrav.client@infinitebrahmanuniverse/nolb-ts-m@everything-registry/sub-chunk-2977@trycreo/sdkhdfvuetemplategj-ts-plugin-packagetencent-ai-sign-tswolfapi-tswd-axiosxax-componentxclxcl-coreteeworlds-utilitiessparse-merkle-treespire_rss-fetcherstory-book-uisuzylive-sdksws-micro-app-adapter-mobilesws-micro-app-adapter-webuulala-componentsvue-experience-components@dmamontov/graphql-mesh-response-cache-plugin@dmamontov/graphql-mesh-audit-log-plugin@dmamontov/graphql-mesh-document-cache-plugin@drodil/backstage-plugin-toolbox@context-labs/autodoc@contextmap/typescript-compiletime@prismadelabs/prismaidjsutilitysdkionic-meumobi-utilskit-room-webkhalalayer-publisherkuxiarqyl-micro-web-componentshdfvueframeworkunixdbsockery@genkit-ai/chromadb@genkit-ai/pineconestrive-molustrive-molu-axiossoonmapstartup-55ukeysuitetoccata-prototypetranslate_chilitm-fanyithunderdigital-nextto-waterfalltrucuniplat-sdk@aipmorg/chat@aipmui/ui@apm-insight-web/upload-sourcemaps@archimedes/arch@asemin/nestjs-utils@aqeed/aqeedshared@arietta-studio/ui@aletriram/utils@aws-quickstart/eks-blueprints@balmacefa/function_tool_kit@bamzooka/ui-kit@ayahub/ui@azharrasheed/ngx-avatar@azure/media-stream-library@baxyz/ngx-avatars@buildery/web-cache@buildery/callout@cachemap/core@chkp/cp-mgmt-api-typescript-sdk@clarabridge/unified-angular-components@clockworkdog/media-stream-library-browser@clockworkdog/media-stream-library-node@ackystack/ackystack-utils@adjai/ngx-library@abetterchoice/abc_web_core
1.3.1

3 years ago

1.3.0

3 years ago

1.2.11

3 years ago

1.2.10

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago