Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2003
    Posts
    58

    Question Unanswered: Random Pasword Generation

    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. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    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.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Oct 2003
    Posts
    58

    Cool

    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. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    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.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Oct 2003
    Posts
    58

    Talking

    Thanks for yor help;

    Have a good day

    Jnr.

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    No problem, I also got bored and decided to make this function myself, me thinx it will come in handy!! I neglected to account for the alpha gap in ASCII code, I really should mention that caps are between 65-90, and lower case is 97-122. Sorry about that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •