Random password generator script for asp
Code:
<% Option Explicit %>
<%
Dim X
Response.Write "<HTML>" & vbCrLf
Response.Write "<HEAD>" & vbCrLf
Response.Write "<TITLE> ASP Random Password Generator v1.1</TITLE>" & vbCrLf
Response.Write "</HEAD>" & vbCrLf
Response.Write "<BODY>" & vbCrLf
Response.Write "<FONT FACE=COURIER>" & vbCrLf
Response.Write "<B>Fixed length (10 characters) passwords</B><BR>" & vbCrLf
For X = 0 To 20
Response.Write RandomPW(10) & "<br>" & vbCrLf
Next
Response.Write "<BR><BR><B>Random length passwords</B><BR>" & vbCrLf
For X = 0 To 20
'Set Length to 0 for random password Length
Response.Write RandomPW(0) & "<br>" & vbCrLf
Next
Response.Write "</FONT>" & vbCrLf
Response.Write "</BODY>" & vbCrLf
Response.Write "</HTML>" & vbCrLf
Function RandomPW(myLength)
'These constant are the minimum and maximum length for random
'length passwords. Adjust these values to your needs.
Const minLength = 6
Const maxLength = 20
Dim X, Y, strPW
If myLength = 0 Then
Randomize
myLength = Int((maxLength * Rnd) + minLength)
End If
For X = 1 To myLength
'Randomize the type of this character
Y = Int((3 * Rnd) + 1) '(1) Numeric, (2) Uppercase, (3) Lowercase
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
RandomPW = strPW
End Function
%>