Code for randomly generating user passwords in ASP

Source: Internet
Author: User

Generate a random User Password (good). Note: generate a random password and then email the password to the registered user. You can confirm that the user's email is correct.
Note: You can randomly generate a password and then email it to the registered user. You can confirm that the user's email is correct. Automatically Generated passwords are often more secure. At the same time, you can filter invalid users.
Set the following Code Save as the random. asp file: Copy code The Code is as follows: <%
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
%>

then you can call the above Code in your target Program to automatically generate the password: (just an example, you can paste them into a test. ASP file, and then run test. ASP) copy the Code the code is as follows:
<%
'generates a six-digit password
strrandomize CSTR (now) & CSTR (RND)
response. write generatepassword (6)
%>
<%
'generate an 8-bit password
strrandomize CSTR (now) & CSTR (RND)
response. write generatepassword (8)
%>
<%
'generate a 10-bit password
strrandomize CSTR (now) & CSTR (RND)
response. write generatepassword (10)
%>
<%
'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 "
"
next
%>

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.