Random | Random description: By randomly generating a password, and then email the password to registered users, you can confirm that the user's email is correct. Automatically generated passwords tend to be more secure, and you can filter out users who are not valid.
Save the following code as a random.asp file:
<%
Sub strrandomize (Strseed)
Dim I, Nseed
Nseed = CLng (0)
For i = 1 to Len (strseed)
Nseed = Nseed Xor (256 * ((I-1) Mod 4) * AscB (Mid (Strseed, I, 1)))
Next
Randomize Nseed
End Sub
Function Generatepassword (nlength)
Dim I, Bmadeconsonant, C, nrnd
Const strdoubleconsonants = "Bdfglmnpst"
Const strconsonants = "Bcdfghklmnpqrstv"
Const strvocal = "Aeiou"
Generatepassword = ""
Bmadeconsonant = False
For i = 0 to Nlength
Nrnd = Rnd
If Generatepassword <> "" and (Bmadeconsonant <> True) and (Nrnd < 0.15) Then
c = Mid (Strdoubleconsonants, Int (Len (strdoubleconsonants) * Rnd + 1), 1)
c = C & C
i = i + 1
Bmadeconsonant = True
Else
If (bmadeconsonant <> True) and (Nrnd < 0.95) Then
c = Mid (Strconsonants, Int (Len (strconsonants) * Rnd + 1), 1)
Bmadeconsonant = True
Else
c = Mid (Strvocal,int (Len (strvocal) * Rnd + 1), 1)
Bmadeconsonant = False
End If
End If
Generatepassword = Generatepassword & C
Next
If Len (Generatepassword) > Nlength Then
Generatepassword = Left (Generatepassword, nlength)
End If
End Function
%>
You can then invoke the above code in your target program to automate the password generation: (Just an example, you can paste them into a test.asp file and run test.asp)
<!--include file= "random.asp"-->
<%
' Generates a six-bit password
Strrandomize CStr (now) & CStr (RND)
Response.Write Generatepassword (6)
%>
<br><br>
<%
' Generates a 8-bit password
Strrandomize CStr (now) & CStr (RND)
Response.Write Generatepassword (8)
%>
<br><br>
<%
' Generates a 10-bit password
Strrandomize CStr (now) & CStr (RND)
Response.Write Generatepassword (10)
%>
<br><br>
<%
' Generates 1000 passwords
Dim T, T2
For t = 1 to 500
For t2 = 1 to 661
Strrandomize CStr (now) & CStr (RND)
Next
Strrandomize CStr (now) & CStr (RND)
Response.Write Generatepassword (6)
Response.Write "<br>"
Next
%>