DefinitelyTyped/types/md5/md5-tests.ts
Piotr Błażejewicz (Peter Blazejewicz) d92f6a5650
feat(node-md5): minor change to support options (#43618)
- version bump to 2.2
- creation time options support
https://github.com/pvorb/node-md5/blob/master/md5.js#L150
- minor changes to rebrush package definition.

Thanks!
2020-04-10 19:45:17 -07:00

14 lines
528 B
TypeScript

import md5 = require('md5');
const message = 'message';
console.log(md5(message)); // should print 78e731027d8fd50ed642340b7c9a63b3
const array = new Array<number>(message.length);
for (let i = 0; i < message.length; ++i) array[i] = message.charCodeAt(i);
const buffer = new Buffer(array);
console.log(md5(buffer)); // Should be same result as above.
const hash1 = md5('abc', { asString: true });
const hash2 = md5(hash1 + 'a', { asString: true, encoding: 'binary' });
const hash3 = md5(hash1 + 'a', { encoding: 'binary' });