Skip to content

Instantly share code, notes, and snippets.

@hiratara
Created February 9, 2009 00:31
Show Gist options
  • Save hiratara/60580 to your computer and use it in GitHub Desktop.
Save hiratara/60580 to your computer and use it in GitHub Desktop.
<html>
<head>
<script type="text/javascript">
function push_codes(arr, char1, char2){
for(var i = char1.charCodeAt(0) ; i <= char2.charCodeAt(0); i++){
arr.push( String.fromCharCode(i) );
}
}
function make_password(alpha, len){
var chars = new Array();
for(var i = 0; i < len; i++){
var pos = Math.floor( Math.random() * alpha.length );
chars.push( alpha[pos] );
}
return chars.join('');
}
var alpha = new Array();
( function (){
push_codes(alpha, "a", "z");
push_codes(alpha, "A", "Z");
push_codes(alpha, "0", "9");
alpha.push('/', '.');
/*
for(i in alpha){
document.write(alpha[i] + ' ');
}
*/
} )();
function start(){
for(var i = 0; i < 100; i++){
var pass = make_password(alpha, 8);
document.getElementById("result").innerHTML += pass + "<br>";
}
}
</script>
</head>
<body onload="start();">
<div id="result"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment