node_modules/hybrid-crypto-js/web/hybrid-crypto.js
/**
   * The built-in default seedFile. This seedFile is used when entropy
   * is needed immediately.
   *
   * @param needed the number of bytes that are needed.
   *
   * @return the random bytes.
   */
The built-in default seedFile. This seedFile is used when entropy
is needed immediately.

@param needed the number of bytes that are needed.

@return the random bytes.
The built - in default seedFile . This seedFile is used when entropy is needed immediately . @param needed the number of bytes that are needed . @return the random bytes .
function defaultSeedFile(needed) {
    var getRandomValues = null;
    var globalScope = forge.util.globalScope;
    var _crypto = globalScope.crypto || globalScope.msCrypto;
    if(_crypto && _crypto.getRandomValues) {
      getRandomValues = function(arr) {
        return _crypto.getRandomValues(arr);
      };
    }
    var b = forge.util.createBuffer();
    if(getRandomValues) {
      while(b.length() < needed) {
        var count = Math.max(1, Math.min(needed - b.length(), 65536) / 4);
        var entropy = new Uint32Array(Math.floor(count));
        try {
          getRandomValues(entropy);
          for(var i = 0; i < entropy.length; ++i) {
            b.putInt32(entropy[i]);
          }
        } catch(e) {
          if(!(typeof QuotaExceededError !== 'undefined' &&
            e instanceof QuotaExceededError)) {
            throw e;
          }
        }
      }
    }
    if(b.length() < needed) {
      var hi, lo, next;
      var seed = Math.floor(Math.random() * 0x010000);
      while(b.length() < needed) {
        lo = 16807 * (seed & 0xFFFF);
        hi = 16807 * (seed >> 16);
        lo += (hi & 0x7FFF) << 16;
        lo += hi >> 15;
        lo = (lo & 0x7FFFFFFF) + (lo >> 31);
        seed = lo & 0xFFFFFFFF;
        for(var i = 0; i < 3; ++i) {
          next = seed >>> (i << 3);
          next ^= Math.floor(Math.random() * 0x0100);
          b.putByte(String.fromCharCode(next & 0xFF));
        }
      }
    }
    return b.getBytes(needed);
  }
function defaultSeedFile ( needed ) { var getRandomValues = null ; var globalScope = forge . util . globalScope ; var _crypto = globalScope . crypto || globalScope . msCrypto ; if ( _crypto && _crypto . getRandomValues ) { getRandomValues = function ( arr ) { return _crypto . getRandomValues ( arr ) ; } ; } var b = forge . util . createBuffer ( ) ; if ( getRandomValues ) { while ( b . length ( ) < needed ) { var count = Math . max ( 1 , Math . min ( needed - b . length ( ) , 65536 ) / 4 ) ; var entropy = new Uint32Array ( Math . floor ( count ) ) ; try { getRandomValues ( entropy ) ; for ( var i = 0 ; i < entropy . length ; ++ i ) { b . putInt32 ( entropy [ i ] ) ; } } catch ( e ) { if ( ! ( typeof QuotaExceededError !== 'undefined' && e instanceof QuotaExceededError ) ) { throw e ; } } } } if ( b . length ( ) < needed ) { var hi , lo , next ; var seed = Math . floor ( Math . random ( ) * 0x010000 ) ; while ( b . length ( ) < needed ) { lo = 16807 * ( seed & 0xFFFF ) ; hi = 16807 * ( seed >> 16 ) ; lo += ( hi & 0x7FFF ) << 16 ; lo += hi >> 15 ; lo = ( lo & 0x7FFFFFFF ) + ( lo >> 31 ) ; seed = lo & 0xFFFFFFFF ; for ( var i = 0 ; i < 3 ; ++ i ) { next = seed >>> ( i << 3 ) ; next ^= Math . floor ( Math . random ( ) * 0x0100 ) ; b . putByte ( String . fromCharCode ( next & 0xFF ) ) ; } } } return b . getBytes ( needed ) ; }
The built-in default seedFile.
The built - in default seedFile .
// use window.crypto.getRandomValues strong source of entropy if available // max byte length is 65536 before QuotaExceededError is thrown // http://www.w3.org/TR/WebCryptoAPI/#RandomSource-method-getRandomValues /* only ignore QuotaExceededError */ // be sad and add some weak random data /* Draws from Park-Miller "minimal standard" 31 bit PRNG,
      implemented with David G. Carta's optimization: with 32 bit math
      and without division (Public Domain). */ // consume lower 3 bytes of seed // throw in more pseudo random