GitXplorerGitXplorer
k

get-random-values

public
18 stars
7 forks
5 issues

Commits

List of commits on branch master.
Unverified
e7319c6f25e2ffefc044e781c147d737ab85a972

chore(deps): @types/tape@5.8.0

rrenovate[bot] committed a month ago
Unverified
9f1d9c10183496d589bbb5df8911388a4e98ac9d

chore(deps): typescript@5.7.2

rrenovate[bot] committed a month ago
Unverified
6502d1828a88abc1ac7df40cc3a40c08b9b9d6f5

chore(deps): @types/tape@5.6.5

rrenovate[bot] committed a month ago
Unverified
776614003f3a4ea27b1f310686995039b10529a6

chore(ci): update bahmutov/npm-install action to v1.10.5

rrenovate[bot] committed a month ago
Unverified
6b7c45ac2df947cbf0442f2a65c6d7a200366659

chore(deps): @kenan/eslint-config@11.1.11

rrenovate[bot] committed 2 months ago
Unverified
9c669835aff419950f94f3b6d7c55d2e0536ead7

chore(deps): type-coverage@2.29.7

rrenovate[bot] committed 2 months ago

README

The README file for this repository.

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.