md5 Hashing algorithm in node.js


MD5 stands for message digest 5 is a widely used hash function which produces 128-bit hashes. We are generating a simple hash using md5 hashing algorithm of node.js


//Loading the crypto module in node.js
var crypto = require('crypto');
//creating hash object 
var hash = crypto.createHash('md5');
//passing the data to be hashed
data = hash.update('nodejsera', 'utf-8');
//Creating the hash in the required format
gen_hash= data.digest('hex');
//Printing the output on the console
console.log("hash : " + gen_hash);



  • Now run the snippet using the following command :
    >node md5-hash.js
    hash : b95ed0bc44d12e3d6cb2ce8b15e1a41f