diff --git a/lib/crypto.js b/lib/crypto.js index bfe7837cb4ea54..ff5e8b00f0fea6 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -647,7 +647,13 @@ exports.setEngine = function setEngine(id, flags) { return binding.setEngine(id, flags); }; -exports.randomBytes = exports.pseudoRandomBytes = randomBytes; +exports.randomBytes = exports.pseudoRandomBytes = function(size, callback) { + if (typeof callback === 'function') { + const warning = 'using randomBytes asynchronously with a callback is deprecated.'; + internalUtil.printDeprecationMessage(warning); + } + return randomBytes(size, callback); +}; exports.rng = exports.prng = randomBytes;