Skip to content

Instantly share code, notes, and snippets.

@ben182
Created January 9, 2018 11:09
Show Gist options
  • Select an option

  • Save ben182/0ea68c391f2d3a51de10b484d92d4244 to your computer and use it in GitHub Desktop.

Select an option

Save ben182/0ea68c391f2d3a51de10b484d92d4244 to your computer and use it in GitHub Desktop.
Better Math.random
(function () {
var MathRandom = Math.random;
Math.random = function() {
var crypto = window.crypto || window.msCrypto;
if (crypto !== undefined) {
return crypto.getRandomValues(new Uint32Array(1))[0] / 4294967296;
}
return MathRandom();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment