Skip to content

Instantly share code, notes, and snippets.

@naosim
Created April 7, 2015 06:00
Show Gist options
  • Save naosim/1f511874ccec59a62773 to your computer and use it in GitHub Desktop.
Save naosim/1f511874ccec59a62773 to your computer and use it in GitHub Desktop.
var MD5 = function() {
var crypto = require('crypto');
return {
hex: function(src) {
var md5 = crypto.createHash('md5');
md5.update(src, 'utf8');
return md5.digest('hex');
}
};
};
if (require.main === module) {
console.log(MD5().hex(process.argv[2]));
} else {
module.exports = MD5;
}
@naosim
Copy link
Author

naosim commented Apr 7, 2015

from console

node md5.js "hoge"

from program

var MD5 = require('md5.js');
MD5().hex('hoge');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment