SHA384 Hashing algorithm in node.js


Secure Hash Algorithm 384 comes under SHA2 and it is a cryptographic hash function which is used to generate hash values.It produces a 384-bit hash value which is known as message digest. Code snippet is given below :


//Name of the file : sha384-hash.js
//Loading the crypto module in node.js
var crypto = require('crypto');
//creating hash object 
var hash = crypto.createHash('sha384');
//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 sha384-hash.js
    hash : 13cd574a1025ab510115701cccbb23539d7144c45ffff3909e09413362fe1b83dad99cb143f5cb311cdeb4921ec6a33e