Created
May 18, 2022 06:51
-
-
Save IvanAdmaers/f1d7fc0f98dff9e5d08cd2a5a7fbfaab to your computer and use it in GitHub Desktop.
Create MD5 signature NodeJS | JavaScript | TypeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createMD5Signature from './createMD5Signature'; | |
describe('createMD5Signature', () => { | |
it('should return a correct hash', () => { | |
expect(createMD5Signature('JohnSmith:9129s$aW}a1')).toBe( | |
'6436241bc4170549efac409b8a4fc43f' | |
); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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