Skip to content

Instantly share code, notes, and snippets.

@CoolOppo
Created June 13, 2015 05:51
Show Gist options
  • Save CoolOppo/d3e727e7d60903975178 to your computer and use it in GitHub Desktop.
Save CoolOppo/d3e727e7d60903975178 to your computer and use it in GitHub Desktop.
var a = [];
for (i = 33; 126 >= i; i++) a.push(String.fromCharCode(i));
var array = new Uint32Array(12);
window.crypto.getRandomValues(array);
var password = '';
for (var i = 0; i < array.length; i++) {
password += a[Math.round(array[i] / 4294967296 * a.length-1)];
}
console.log(password);
for(var a=[],b=33;126>=b;b++)a.push(String.fromCharCode(b));var c=new Uint32Array(12);window.crypto.getRandomValues(c);for(var d="",b=0;b<c.length;b++)d+=a[Math.round(c[b]/4294967296*a.length-1)];console.log(d);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment