Last active
December 12, 2018 17:17
-
-
Save remarkablemark/ef52f3fb1c16cf7aaf8aae1fc81aceca to your computer and use it in GitHub Desktop.
Calculate the MD5 hash of a string using Node.js
This file contains hidden or 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
'use strict'; | |
/** | |
* Module dependencies. | |
*/ | |
var crypto = require('crypto'); | |
/** | |
* Calculates the MD5 hash of a string. | |
* | |
* @param {String} string - The string (or buffer). | |
* @return {String} - The MD5 hash. | |
*/ | |
function md5(string) { | |
return crypto.createHash('md5').update(string).digest('hex'); | |
} | |
module.exports = md5; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@remarkablemark
I think,
.update(data)
should be.update(string)
in this example