feat(md5): now creates md5 hashes

This commit is contained in:
Philipp Kunz 2019-11-21 14:17:48 +00:00
parent cb5b3d2172
commit 0ed76d1ad4
5 changed files with 326 additions and 390 deletions

689
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -29,17 +29,17 @@
}, },
"homepage": "https://github.com/pushrocks/nodehash#readme", "homepage": "https://github.com/pushrocks/nodehash#readme",
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.11", "@gitzone/tsbuild": "^2.1.17",
"@gitzone/tsrun": "^1.2.6", "@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.24", "@gitzone/tstest": "^1.0.28",
"@pushrocks/tapbundle": "^3.0.11", "@pushrocks/tapbundle": "^3.2.0",
"@types/node": "^12.0.12", "@types/node": "^12.12.11",
"tslint": "^5.18.0", "tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartjson": "^3.0.5", "@pushrocks/smartjson": "^3.0.8",
"@pushrocks/smartpromise": "^3.0.2", "@pushrocks/smartpromise": "^3.0.6",
"@types/through2": "^2.0.34", "@types/through2": "^2.0.34",
"through2": "^3.0.1" "through2": "^3.0.1"
}, },

View File

@ -47,4 +47,9 @@ tap.test('should produce reproducible hash from Object', async () => {
expect(hash1).to.not.equal(hash3); expect(hash1).to.not.equal(hash3);
}); });
tap.test('should create md5hash from string', async () => {
const md5Hash = await smarthash.md5FromString('hellothere');
expect(md5Hash).to.equal('c6f7c372641dd25e0fddf0215375561f');
});
tap.start(); tap.start();

View File

@ -1,3 +1,4 @@
import * as plugins from './nodehash.plugins'; import * as plugins from './nodehash.plugins';
export * from './nodehash.sha256'; export * from './nodehash.sha256';
export * from './nodehash.md5';

5
ts/nodehash.md5.ts Normal file
View File

@ -0,0 +1,5 @@
import * as plugins from './nodehash.plugins';
export const md5FromString = async (stringToHash: string) => {
return plugins.crypto.createHash('md5').update(stringToHash).digest("hex");
};