mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
crypto.randomFill and crypto.randomFillSync are similar to crypto.randomBytes, but allow passing in a buffer as the first argument. This allows us to reuse buffers to prevent having to create a new one on every call. PR-URL: https://github.com/nodejs/node/pull/10209 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net>
23 lines
674 B
JavaScript
23 lines
674 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto)
|
|
common.skip('node compiled without OpenSSL.');
|
|
|
|
const crypto = require('crypto');
|
|
|
|
// Pollution of global is intentional as part of test.
|
|
common.globalCheck = false;
|
|
// See https://github.com/nodejs/node/commit/d1eff9ab
|
|
global.domain = require('domain');
|
|
|
|
// should not throw a 'TypeError: undefined is not a function' exception
|
|
crypto.randomBytes(8);
|
|
crypto.randomBytes(8, common.mustCall());
|
|
const buf = Buffer.alloc(8);
|
|
crypto.randomFillSync(buf);
|
|
crypto.pseudoRandomBytes(8);
|
|
crypto.pseudoRandomBytes(8, common.mustCall());
|
|
crypto.pbkdf2('password', 'salt', 8, 8, 'sha1', common.mustCall());
|