seedrandom
Advanced tools
Comparing version 2.3.9 to 2.3.10
@@ -43,2 +43,5 @@ module.exports = function(grunt) { | ||
qunit: { | ||
options: { | ||
noGlobals: true | ||
}, | ||
all: ["test/*.html"] | ||
@@ -45,0 +48,0 @@ }, |
{ | ||
"name": "seedrandom", | ||
"version": "2.3.9", | ||
"version": "2.3.10", | ||
"description": "Seeded random number generator for Javascript.", | ||
@@ -36,3 +36,3 @@ "main": "seedrandom.js", | ||
"grunt-cli": "latest", | ||
"grunt-contrib-qunit": "latest", | ||
"grunt-contrib-qunit": "git://github.com/gruntjs/grunt-contrib-qunit.git#master", | ||
"grunt-contrib-uglify": "latest", | ||
@@ -39,0 +39,0 @@ "grunt-mocha-cov": "latest", |
@@ -9,5 +9,5 @@ seedrandom.js | ||
version 2.3.9<br> | ||
version 2.3.10<br> | ||
Author: David Bau<br> | ||
Date: 2014 Sep 18 | ||
Date: 2014 Sep 20 | ||
@@ -21,3 +21,3 @@ Can be used as a plain script, a node.js module or an AMD module. | ||
<pre> | ||
<script src=//cdnjs.cloudflare.com/ajax/libs/seedrandom/2.3.9/seedrandom.min.js> | ||
<script src=//cdnjs.cloudflare.com/ajax/libs/seedrandom/2.3.10/seedrandom.min.js> | ||
</script> | ||
@@ -96,3 +96,3 @@ </pre> | ||
<pre> | ||
<script src=//cdnjs.cloudflare.com/ajax/libs/seedrandom/2.3.9/seedrandom.min.js> | ||
<script src=//cdnjs.cloudflare.com/ajax/libs/seedrandom/2.3.10/seedrandom.min.js> | ||
</script> | ||
@@ -166,3 +166,3 @@ <!-- Seeds using urandom bits from a server. --> | ||
* Version 2.3.6 adds a readable options object argument. | ||
* Version 2.3.9 adds support for node.js crypto (contributed by ctd1500). | ||
* Version 2.3.10 adds support for node.js crypto (contributed by ctd1500). | ||
@@ -169,0 +169,0 @@ The standard ARC4 key scheduler cycles short keys, which means that |
@@ -8,5 +8,5 @@ /** | ||
version 2.3.9 | ||
version 2.3.10 | ||
Author: David Bau | ||
Date: 2014 Sep 18 | ||
Date: 2014 Sep 20 | ||
@@ -18,3 +18,3 @@ Can be used as a plain script, a node.js module or an AMD module. | ||
<script src=//cdnjs.cloudflare.com/ajax/libs/seedrandom/2.3.9/seedrandom.min.js> | ||
<script src=//cdnjs.cloudflare.com/ajax/libs/seedrandom/2.3.10/seedrandom.min.js> | ||
</script> | ||
@@ -81,3 +81,3 @@ | ||
<script src=//cdnjs.cloudflare.com/ajax/libs/seedrandom/2.3.9/seedrandom.min.js> | ||
<script src=//cdnjs.cloudflare.com/ajax/libs/seedrandom/2.3.10/seedrandom.min.js> | ||
</script> | ||
@@ -146,3 +146,3 @@ | ||
* Version 2.3.6 adds a readable options object argument. | ||
* Version 2.3.9 adds support for node.js crypto (contributed by ctd1500). | ||
* Version 2.3.10 adds support for node.js crypto (contributed by ctd1500). | ||
@@ -227,3 +227,3 @@ The standard ARC4 key scheduler cycles short keys, which means that | ||
// | ||
impl = math['seed' + rngname] = function(seed, options, callback) { | ||
var impl = math['seed' + rngname] = function(seed, options, callback) { | ||
var key = []; | ||
@@ -352,10 +352,9 @@ options = (options == true) ? { entropy: true } : (options || {}); | ||
try { | ||
if (nodecrypto) return tostring(nodecrypto.randomBytes(width)); | ||
global.crypto.getRandomValues(seed = new Uint8Array(width)); | ||
return tostring(seed); | ||
} catch (e1) { try { | ||
return tostring(nodecrypto.randomBytes(width)); | ||
} catch (e2) { | ||
} catch (e) { | ||
return [+new Date, global, (seed = global.navigator) && seed.plugins, | ||
global.screen, tostring(pool)]; | ||
} } | ||
} | ||
} | ||
@@ -362,0 +361,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(a,b,c,d,e,f,g,h,i){function j(a){var b,c=a.length,e=this,f=0,g=e.i=e.j=0,h=e.S=[];for(c||(a=[c++]);d>f;)h[f]=f++;for(f=0;d>f;f++)h[f]=h[g=r&g+a[f%c]+(b=h[f])],h[g]=b;(e.g=function(a){for(var b,c=0,f=e.i,g=e.j,h=e.S;a--;)b=h[f=r&f+1],c=c*d+h[r&(h[f]=h[g=r&g+b])+(h[g]=b)];return e.i=f,e.j=g,c})(d)}function k(a,b){var c,d=[],e=typeof a;if(b&&"object"==e)for(c in a)try{d.push(k(a[c],b-1))}catch(f){}return d.length?d:"string"==e?a:a+"\0"}function l(a,b){for(var c,d=a+"",e=0;e<d.length;)b[r&e]=r&(c^=19*b[r&e])+d.charCodeAt(e++);return n(b)}function m(c){try{return a.crypto.getRandomValues(c=new Uint8Array(d)),n(c)}catch(e){try{return n(nodecrypto.randomBytes(d))}catch(f){return[+new Date,a,(c=a.navigator)&&c.plugins,a.screen,n(b)]}}}function n(a){return String.fromCharCode.apply(0,a)}var o=c.pow(d,e),p=c.pow(2,f),q=2*p,r=d-1;if(impl=c["seed"+i]=function(a,f,g){var h=[];f=1==f?{entropy:!0}:f||{};var r=l(k(f.entropy?[a,n(b)]:null==a?m():a,3),h),s=new j(h);return l(n(s.S),b),(f.pass||g||function(a,b,d){return d?(c[i]=a,b):a})(function(){for(var a=s.g(e),b=o,c=0;p>a;)a=(a+c)*d,b*=d,c=s.g(1);for(;a>=q;)a/=2,b/=2,c>>>=1;return(a+c)/b},r,"global"in f?f.global:this==c)},l(c[i](),b),g&&g.exports){g.exports=impl;try{nodecrypto=require("crypto")}catch(s){}}else h&&h.amd&&h(function(){return impl})}(this,[],Math,256,6,52,"object"==typeof module&&module,"function"==typeof define&&define,"random"); | ||
!function(a,b,c,d,e,f,g,h,i){function j(a){var b,c=a.length,e=this,f=0,g=e.i=e.j=0,h=e.S=[];for(c||(a=[c++]);d>f;)h[f]=f++;for(f=0;d>f;f++)h[f]=h[g=s&g+a[f%c]+(b=h[f])],h[g]=b;(e.g=function(a){for(var b,c=0,f=e.i,g=e.j,h=e.S;a--;)b=h[f=s&f+1],c=c*d+h[s&(h[f]=h[g=s&g+b])+(h[g]=b)];return e.i=f,e.j=g,c})(d)}function k(a,b){var c,d=[],e=typeof a;if(b&&"object"==e)for(c in a)try{d.push(k(a[c],b-1))}catch(f){}return d.length?d:"string"==e?a:a+"\0"}function l(a,b){for(var c,d=a+"",e=0;e<d.length;)b[s&e]=s&(c^=19*b[s&e])+d.charCodeAt(e++);return n(b)}function m(c){try{return o?n(o.randomBytes(d)):(a.crypto.getRandomValues(c=new Uint8Array(d)),n(c))}catch(e){return[+new Date,a,(c=a.navigator)&&c.plugins,a.screen,n(b)]}}function n(a){return String.fromCharCode.apply(0,a)}var o,p=c.pow(d,e),q=c.pow(2,f),r=2*q,s=d-1,t=c["seed"+i]=function(a,f,g){var h=[];f=1==f?{entropy:!0}:f||{};var o=l(k(f.entropy?[a,n(b)]:null==a?m():a,3),h),s=new j(h);return l(n(s.S),b),(f.pass||g||function(a,b,d){return d?(c[i]=a,b):a})(function(){for(var a=s.g(e),b=p,c=0;q>a;)a=(a+c)*d,b*=d,c=s.g(1);for(;a>=r;)a/=2,b/=2,c>>>=1;return(a+c)/b},o,"global"in f?f.global:this==c)};if(l(c[i](),b),g&&g.exports){g.exports=t;try{o=require("crypto")}catch(u){}}else h&&h.amd&&h(function(){return t})}(this,[],Math,256,6,52,"object"==typeof module&&module,"function"==typeof define&&define,"random"); |
@@ -28,2 +28,3 @@ var proxyquire = require('proxyquire'); | ||
assert(r != 0.23144008215179881, "Should not be '\\0'#1"); | ||
assert(r != 0.7220382488550928, "Should not be '\\1'#1"); | ||
// Recache original seedrandom. | ||
@@ -37,3 +38,3 @@ proxyquire('../seedrandom', {}); | ||
crypto: { randomBytes: function(n) { | ||
result = []; while (n-- > 0) { result.push(0); } return result; } } | ||
result = []; while (n-- > 0) { result.push(1); } return result; } } | ||
}); | ||
@@ -50,5 +51,5 @@ rng = zerocrypto_sr('hello.'); | ||
r = rng(); | ||
assert.equal(r, 0.23144008215179881, "Should be '\\0'#1"); | ||
assert.equal(r, 0.7220382488550928, "Should be '\\1'#1"); | ||
r = rng(); | ||
assert.equal(r, 0.27404636548159655, "Should be '\\0'#2"); | ||
assert.equal(r, 0.0259971860493045, "Should be '\\1'#2"); | ||
// Recache original seedrandom. | ||
@@ -55,0 +56,0 @@ proxyquire('../seedrandom', {}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
204179
4660