random.js 1.6 KB

1
  1. (function(){function k(c){c.random=c.random||{};(function(g){var a={},e=Array(4),d=c.util.createBuffer();a.formatKey=function(b){var a=c.util.createBuffer(b);b=Array(4);b[0]=a.getInt32();b[1]=a.getInt32();b[2]=a.getInt32();b[3]=a.getInt32();return c.aes._expandKey(b,!1)};a.formatSeed=function(b){var a=c.util.createBuffer(b);b=Array(4);b[0]=a.getInt32();b[1]=a.getInt32();b[2]=a.getInt32();b[3]=a.getInt32();return b};a.cipher=function(a,f){c.aes._updateBlock(a,f,e,!1);d.putInt32(e[0]);d.putInt32(e[1]);d.putInt32(e[2]);d.putInt32(e[3]);return d.getBytes()};a.increment=function(a){++a[3];return a};a.md=c.md.sha1;var f=c.prng.create(a);f.collectInt(+new Date,32);if("undefined"!==typeof navigator){a="";for(var h in navigator)try{"string"==typeof navigator[h]&&(a+=navigator[h])}catch(b){}f.collect(a);a=null}g&&(g().mousemove(function(a){f.collectInt(a.clientX,16);f.collectInt(a.clientY,16)}),g().keypress(function(a){f.collectInt(a.charCode,8)}));c.random=c.random||{};c.random.getBytes=function(a){return f.generate(a)}})("undefined"!==typeof jQuery?jQuery:null)}var l=["./aes","./md","./prng","./util"],h=null;"function"!==typeof define&&("object"===typeof module&&module.exports?h=function(c,g){g(require,module)}:(crosscert=window.crosscert=window.crosscert||{},k(crosscert)));(h||"function"===typeof define)&&(h||define)(["require","module"].concat(l),function(c,g){g.exports=function(a){var e=l.map(function(a){return c(a)}).concat(k);a=a||{};a.defined=a.defined||{};if(a.defined.random)return a.random;a.defined.random=!0;for(var d=0;d<e.length;++d)e[d](a);return a.random}})})();