Example crypto sha256 hmac in nodejs

Example:

 

var crypto = require('crypto');

 

var secret = 'abcdefg';

var message = "I love you";

var hash = crypto.createHmac('sha256', secret).update(message).digest('hex');

console.log(hash);

 

Run :

 

C:\\Nodejs>node cryptoPasswordsh256.js

a3d7754086d8e1d921cfc85cf4b22992698e3fbbc4b3610b782580d78b73b997