Nodejs
Nodejs Code Snippet
Hash Email and Phone Number
Dependency:
const crypto = require('crypto');: This imports the built-incryptomodule in Node.js, which provides cryptographic functionality.
const crypto = require('crypto');
function hashSHA256(input) {
const hash = crypto.createHash('sha256');
hash.update(input);
return hash.digest('hex');
}
// Example usage
const email = '[email protected]';
const phone = '+1234567890';
// Hash email
const emailHash = hashSHA256(email);
console.log('Hashed email:', emailHash);
// Hash phone number
const phoneHash = hashSHA256(phone);
console.log('Hashed phone number:', phoneHash);
Encrypt Signed body
Dependency:
crypto: This built-in Node.js module provides cryptographic functionalities including hashing, encryption, and decryption.
Last updated