crypto
property
Provides cryptographic functionality including hashing, HMAC, encryption, and random bytes generation.
Syntax
const crypto = require('crypto')
Example
javascript
const crypto = require('crypto');
// Hash a password (use bcrypt in production)
const hash = crypto.createHash('sha256').update('password').digest('hex');
// Secure random token
const token = crypto.randomBytes(32).toString('hex');
// HMAC signature
const hmac = crypto.createHmac('sha256', 'secret-key')
.update('data')
.digest('hex');
// UUID-like random ID
const id = crypto.randomUUID(); // built-in since Node 14.17