PDA

View Full Version : Key generation



micklep
12-19-2006, 12:10 PM
I am new to javascript but i have created these number and key gens. Tell me if you can find a use please:

key gen:
http://www.stuff.pissedandhappy.co.uk/password-gen.txt

and the number gen:
http://www.stuff.pissedandhappy.co.uk/numbergen.html

To get a new number or key just refresh.

The script works on the "Math.random" code, it is simply 10 codes running against each other. Anyway, any use of these what so ever would be great.

Peter

BLiZZaRD
12-19-2006, 12:46 PM
Wouldn't it be better (and shorter) to make an alphanumeric array from which the 10 spots just pulled from the same pool?

Instead of giving each a finite set of numbers/letters.

If I refresh enough times I will see the same code.

I can't think of any practical uses for it the way it is now though.

djr33
12-20-2006, 12:27 AM
And the fact that it all exists as seperate script is just awkward.

There's already a thread going about this, where I posted a PHP example of a generator that actually grabs a random character, not just a predefined character based on a random number.

http://www.dynamicdrive.com/forums/showthread.php?t=15831


<?php
$len = 8; //set pass length //in this case, 8
for ($n=0;$n<$len;$n++) { //loop starting at 0, while less than len value
$ord = rand(1,62); //10num+26LET+26let //add more if you want
if ($ord <= 10) {$ord += 47;} //numbers
else if ($ord <= 36) {$ord += 54;} //LETTERS
else { $ord += 60; } //letters
//include other sets of chars if you want
$pass .= chr($ord); //add char to existing password
}
echo $pass; //output password
?>
http://ci-pro.com/misc/phptest/passgen.php
Test page^.

BLiZZaRD
12-20-2006, 09:18 AM
OOO nice one djr. I like that little snippet. May I use that on my site?? :D