Node.js crypto module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign and verify functions. Use this tag for questions related to Node.js applications/scripts that use crypto module - require('crypto').
node-crypto should be used on questions related to cryptography api of node.js
The
crypto
module provides cryptographic functionality that includes a set of wrappers forOpenSSL's hash
,HMAC
,cipher
,decipher
,sign
andverify
functions.
Sample
// Import module.
const crypto = require('crypto');
// Prepare secret.
const secret = 'very secret';
// Create hash.
const hash = crypto.createHmac('sha256', secret)
.update('sample information')
.digest('hex');
// Print it.
console.log(hash);
// => 5087be71f85fd1ea755742b0fe4eaf5a7c4c25bee5db58f4f7edd1558ed792d0
References