View Full Version : Key generation

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:

and the number gen:

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.


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.

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.


$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
Test page^.

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