|
|
пре 1 година | |
|---|---|---|
| .. | ||
| dist | пре 1 година | |
| src | пре 1 година | |
| LICENSE | пре 1 година | |
| README.md | пре 1 година | |
| package.json | пре 1 година | |
A MD5 implementation for TypeScript
This library also includes tools for:
Based on work by
Install the node module with npm install ts-md5
import {Md5} from 'ts-md5';Md5.hashStr('blah blah blah') => hex:stringMd5.hashStr('blah blah blah', true) => raw:Int32Array(4)Md5.hashAsciiStr('blah blah blah') => hex:stringMd5.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();
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);
});
The project is written in typescript and transpiled into ES5.
npm install -g typescript (if you haven't already)tsconfig.jsontscYou can find more information here: https://github.com/Microsoft/TypeScript/wiki/tsconfig.json
npm run buildnpm run testpackage.json https://docs.npmjs.com/files/package.jsonnpm publish https://docs.npmjs.com/cli/publishMIT