Description
In recent Node.js versions, crypto.pseudoRandomBytes is a deprecated alias for crypto.randomBytes. Both names generate cryptographically strong random bytes.
Potential impact
Code using the alias may fail if a future Node.js release removes it.
Remediation
Replace the alias with crypto.randomBytes. Keep the existing callback or synchronous return handling and remove any compatibility branches you no longer need. Check the deprecation notice for the Node.js versions you support.
Examples
Before
javascript
const crypto = require('crypto');
// Use the deprecated alias.
const randomValue = crypto.pseudoRandomBytes(16);
console.log(randomValue.toString('hex'));
After
javascript
const crypto = require('crypto');
// Use the current API name.
const randomValue = crypto.randomBytes(16);
console.log(randomValue.toString('hex'));
Both examples generate 16 bytes synchronously and display them as hex.