SHA224 Hashing algorithm in node.js


Overview

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

Code


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

													
												

Run

  • Now run the snippet using the following command :
    													
    >node sha224-hash.js
    hash : a259323c32f8c38ccb97fcd3b407a1b51a8b7d9b16f672a8d6cbb2d6