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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

generate a random password 3

Status
Not open for further replies.

Smarty

Programmer
Apr 12, 2001
191
BE
Hi does anyone have the code to generate a random 6 digits password?

Thanx
 
Hi Smarty

Thanks for all the stars by the way.

Try this for numeric only password

Randomize
pword1 = Int((999999 * Rnd) + 1)
Response.write MyValue

or this one for upper case characters only

pword2 = ""
randomize
for a = 1 to 6
pword2 = pword2 & chr(Int((26 * Rnd) + 1)+64)
next
 
Thanx,

I've also another solution found yet:

Dim X, Y, strPW
If myLenght = 0 Then
'Random lenght [6-20]
Randomize
myLenght = Int((20 * Rnd) + 6)
End If
For X = 1 To myLenght
Y = Int((3 * Rnd) + 1) 'Numeric (1), upper (2) or lower (3) case alphabet
Select Case Y
Case 1
'Numeric character
Randomize
strPW = strPW & CHR(Int((9 * Rnd) + 48))
Case 2
'Uppercase character
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 65))
Case 3
'Lowercase character
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 97))
End Select
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top