Package Exports
- get-random-values
- get-random-values/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (get-random-values) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
get-random-values
window.crypto.getRandomValues
or window.msCrypto.getRandomValues
or
require('crypto').randomBytes
or an Error.
Example
var getRandomValues = require('get-random-values');
var array = new Uint32Array(10);
getRandomValues(array);
// => [
// => 183,
// => 76,
// => 18,
// => 177,
// => 73,
// => 9,
// => 50,
// => 248,
// => 216,
// => 104
// => ]
Installation
$ npm install get-random-values
API
var getRandomValues = require('get-random-values');
getRandomValues(buf)
Fills integer-based TypedArray buf
with cryptographically random numbers.
Checks for and uses the first of the following:
window.crypto.getRandomValues
window.msCrypto.getRandomValues
- Node.js crypto
If none of the above are available, then an Error is thrown.
Throws QuotaExceededError if buf.length > 65536
(even if Node.js crypto,
which doesn't have that limit, is being used).
buf
must be a Uint8Array if Node.js crypto is used, otherwise a
TypeError will be thrown.