Nicole
0
Q:

crypto node

const crypto = require('crypto');

const secret = 'abcdefg';
const hash = crypto.createHmac('sha256', secret)
                   .update('I love cupcakes')
                   .digest('hex');
console.log(hash);
// Prints:
//   c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
5
//To create a random string using crypto
require('crypto').randomBytes(64).toString('hex')
//3f19d8644bcb8afa0668ac2d9bffd5c88b85c165ccb0546622305911659ab3361b62acc3dd87097c7280e31517fd4a3413c553787da9805397a22c89a4ed98da
1

New to Communities?

Join the community