To create a password by random, and then email the password to the registered user

Source: Internet
Author: User
Tags end
By randomly generating a password and then emailing the password to a registered user, you can confirm that the user's email is correctly filled in. 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

Although this may have some trouble, but relative to the safety of the site and other factors, it is worthwhile, see how you choose.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.