build/authorify.js
function defaultSeedFile(needed) {
    // use window.crypto.getRandomValues strong source of entropy if available
    var getRandomValues = null;
    if(typeof window !== 'undefined') {
      var _crypto = window.crypto || window.msCrypto;
      if(_crypto && _crypto.getRandomValues) {
        getRandomValues = function(arr) {
          return _crypto.getRandomValues(arr);
        };
      }
    }

    var b = forge.util.createBuffer();
    if(getRandomValues) {
      while(b.length() < needed) {
        // max byte length is 65536 before QuotaExceededError is thrown
        // http://www.w3.org/TR/WebCryptoAPI/#RandomSource-method-getRandomValues
        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) {
          /* only ignore QuotaExceededError */
          if(!(typeof QuotaExceededError !== 'undefined' &&
            e instanceof QuotaExceededError)) {
            throw e;
          }
        }
      }
    }

    // be sad and add some weak random data
    if(b.length() < needed) {
      /* 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). */
      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;

        // consume lower 3 bytes of seed
        for(var i = 0; i < 3; ++i) {
          // throw in more pseudo random
          next = seed >>> (i << 3);
          next ^= Math.floor(Math.random() * 0x0100);
          b.putByte(String.fromCharCode(next & 0xFF));
        }
      }
    }

    return b.getBytes(needed);
  }
function defaultSeedFile(needed) {
    // use window.crypto.getRandomValues strong source of entropy if available
    var getRandomValues = null;
    if(typeof window !== 'undefined') {
      var _crypto = window.crypto || window.msCrypto;
      if(_crypto && _crypto.getRandomValues) {
        getRandomValues = function(arr) {
          return _crypto.getRandomValues(arr);
        };
      }
    }

    var b = forge.util.createBuffer();
    if(getRandomValues) {
      while(b.length() < needed) {
        // max byte length is 65536 before QuotaExceededError is thrown
        // http://www.w3.org/TR/WebCryptoAPI/#RandomSource-method-getRandomValues
        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) {
          /* only ignore QuotaExceededError */
          if(!(typeof QuotaExceededError !== 'undefined' &&
            e instanceof QuotaExceededError)) {
            throw e;
          }
        }
      }
    }

    // be sad and add some weak random data
    if(b.length() < needed) {
      /* 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). */
      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;

        // consume lower 3 bytes of seed
        for(var i = 0; i < 3; ++i) {
          // throw in more pseudo random
          next = seed >>> (i << 3);
          next ^= Math.floor(Math.random() * 0x0100);
          b.putByte(String.fromCharCode(next & 0xFF));
        }
      }
    }

    return b.getBytes(needed);
  }
function defaultSeedFile ( needed ) { // use window.crypto.getRandomValues strong source of entropy if available var getRandomValues = null ; if ( typeof window !== 'undefined' ) { var _crypto = window . crypto || window . msCrypto ; if ( _crypto && _crypto . getRandomValues ) { getRandomValues = function ( arr ) { return _crypto . getRandomValues ( arr ) ; } ; } } var b = forge . util . createBuffer ( ) ; if ( getRandomValues ) { while ( b . length ( ) < needed ) { // max byte length is 65536 before QuotaExceededError is thrown // http://www.w3.org/TR/WebCryptoAPI/#RandomSource-method-getRandomValues 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 ) { /* only ignore QuotaExceededError */ if ( ! ( typeof QuotaExceededError !== 'undefined' && e instanceof QuotaExceededError ) ) { throw e ; } } } } // be sad and add some weak random data if ( b . length ( ) < needed ) { /* 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). */ 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 ; // consume lower 3 bytes of seed for ( var i = 0 ; i < 3 ; ++ i ) { // throw in more pseudo random 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. 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 .