[wp-hackers] On overly-obscure passwords
Otto
otto at ottodestruct.com
Wed May 12 17:52:00 UTC 2010
On Wed, May 12, 2010 at 12:16 PM, Rafael Poveda - RaveN <raven at mecus.es> wrote:
> We can use something like http://www.freepasswordgenerator.com/
Why go nuts and use somebody's service when it's so easy to stick one
in there via javascript? Making psuedorandom numbers ain't hard.
demo.html
----
<script type="text/javascript">
function generatePassword(length) {
var password = "";
for (i=0; i < length; i++) {
num = (parseInt(Math.random() * 1000) % 94) + 33;
while (checkPunc(num)) { num = (parseInt(Math.random() * 1000)
% 94) + 33; }
password = password + String.fromCharCode(num);
}
return password;
}
function checkPunc(num) {
if ((num >=33) && (num <=47)) { return true; }
if ((num >=58) && (num <=64)) { return true; }
if ((num >=91) && (num <=96)) { return true; }
if ((num >=123) && (num <=126)) { return true; }
return false;
}
</script>
<h2>Demo JavaScript Password Generator</h2>
<form name="form1">
<p>Generated Password:<br />
<input type="text" name="passfield" value="" size="15"><br />
<input type="button" value="Generate Password"
onClick="document.form1.passfield.value = generatePassword(12)"></p>
</form>
----
-Otto
More information about the wp-hackers
mailing list