Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically creating a password

Status
Not open for further replies.
Joined
Jan 7, 2005
Messages
124
Location
US
Can anyone give me some tips or some sample code showing me how to dynamically create a password...here is my case: an administrator creates a new user in the system, each new user has a tech id that consists of 8 characters (example: a2938987), once the user is created I would like for the system to automatically generate an 8 character password that consists of letters and numbers that will be e-mailed to the new user along with a link to initialize their account...from there they are able to set a password of their choosing. Thanks.
 
I use the following function:

length_of_password = 8

function MakePassword(num)

dim i, intNum, intUpper, intLower, intRand, strPartPass

Randomize

For i = 1 to num
intNum = Int(10 * Rnd + 48)
intUpper = Int(26 * Rnd + 65)
intLower = Int(26 * Rnd + 97)
intRand = Int(3 * Rnd + 1)

Select Case intRand
Case 1
strPartPass = Chr(intNum)
Case 2
strPartPass = Chr(intUpper)
Case 3
strPartPass = Chr(intLower)
End Select

MakePassword = MakePassword & strPartPass
Next

end function

Then display with:

MakePassword(length_of_password)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top