Sha256: fc8c51c0277abbc01e357405e1e64c28b399a363cf07d69121dc69e186c00969

Contents?: true

Size: 719 Bytes

Versions: 36

Compression:

Stored size: 719 Bytes

Contents

// Original code adapted from Robert Kieffer.
// details at https://github.com/broofa/node-uuid
(function() {
  var _global = this;

  var mathRNG, whatwgRNG;

  // NOTE: Math.random() does not guarantee "cryptographic quality"
  mathRNG = function(size) {
    var bytes = new Array(size);
    var r;

    for (var i = 0, r; i < size; i++) {
      if ((i & 0x03) == 0) r = Math.random() * 0x100000000;
      bytes[i] = r >>> ((i & 0x03) << 3) & 0xff;
    }

    return bytes;
  }

  if (_global.crypto && crypto.getRandomValues) {
    whatwgRNG = function(size) {
      var bytes = new Uint8Array(size);
      crypto.getRandomValues(bytes);
      return bytes;
    }
  }

  module.exports = whatwgRNG || mathRNG;

}())

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
sumomo-0.10.8 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.10.4 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.10.3 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.10.2 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.10.1 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.10.0 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.9.0 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.8.22 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.8.21 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.8.20 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.8.17 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.8.16 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.8.15 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.8.14 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.8.13 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.8.12 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.8.11 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.8.10 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.8.9 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js
sumomo-0.8.8 data/sumomo/api_modules/node_modules/crypto-browserify/rng.js