Skip to content

Instantly share code, notes, and snippets.

@IvanAdmaers
Created May 18, 2022 06:51
Show Gist options
  • Save IvanAdmaers/f1d7fc0f98dff9e5d08cd2a5a7fbfaab to your computer and use it in GitHub Desktop.
Save IvanAdmaers/f1d7fc0f98dff9e5d08cd2a5a7fbfaab to your computer and use it in GitHub Desktop.
Create MD5 signature NodeJS | JavaScript | TypeScript
import createMD5Signature from './createMD5Signature';
describe('createMD5Signature', () => {
it('should return a correct hash', () => {
expect(createMD5Signature('JohnSmith:9129s$aW}a1')).toBe(
'6436241bc4170549efac409b8a4fc43f'
);
});
});
import crypto from 'crypto';
/**
* This function creates a MD5 signature
*/
const createMD5Signature = (stringToHash: string): string =>
crypto.createHash('md5').update(stringToHash).digest('hex');
export default createMD5Signature;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment