1. Registered User
Join Date
Oct 2003
Posts
58

Hi all,

I have to bulid a function which generates a random 6 alpha-numeric password, 3xChar + 3xInt.

I havent got the faintest idea where to start! I have a table of passwords already assigned so if at all possible the function would be able to look at the list and find one that was not already assigned.

For all thous who may enquire as to the security level these passwords will be encrypted later on.

Help!

Jnr.

2. Purveyor of Discontent
Join Date
Mar 2003
Location
The Bottom of The Barrel
Posts
6,102
I don't have the time to do it at the moment, but you could use a combination of the Rnd() function, and the Chr() function to create random passwords.

You can use this format to specify bounds:

Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

With that in mind, you could create a few functions, one that would return a random integer (most likely between 0 and 9, since you only need one numeric character). One that would return a random letter (using chr(number), where number = a random number between 65 and 122).

Then you could create a function that would randomly generate either a 1 or a 2, where 1 would call the random integer function, and 2 would call the random alpha function. You could loop through this for as many characters as you need, instant random password.

In your case, you could omit the last step, and use a loop that calls the random letter function 3x, then the random int function 3x.

It's really not that hard, just a bit tedious.
Last edited by Teddy; 06-16-04 at 10:14.

3. Registered User
Join Date
Oct 2003
Posts
58
Thanks,

I have done a few searches and pieced togeather a bit of code.

But am unsure as to what the numbers in this statement mean

MyValue4 = Chr((Int(26 * Rnd()) + 1) + 64)

4. Purveyor of Discontent
Join Date
Mar 2003
Location
The Bottom of The Barrel
Posts
6,102
Well, Rnd returns a number > 0, and < 1. So, Rnd * 26 Is going to give you a number between 1 and 26. You can omit the + 1 if 0 is acceptable. The + 64 is to bring you the specified lower bounds. Int will round the number up or down, and Chr returns the ascii for the number.

They key is in Rnd returning that value between 0 and 1, once you figure out how to use that, you're set.

5. Registered User
Join Date
Oct 2003
Posts
58
Thanks for yor help;

Have a good day

Jnr.

6. Purveyor of Discontent
Join Date
Mar 2003
Location
The Bottom of The Barrel
Posts
6,102