ASP生成随机密码的源代码asp

/ / 2016-06-05   阅读:2498
 密码是一种身份验证的手段,使用密码的目的不是密码本身要容易记忆,重要的是让不怀好意的人难以猜到。根据密码本身的保密程度,相隔一定时间后要进行修改。应尽量避免记录在并不安全的纸质介质上,也不要使用...
 密码是一种身份验证的手段,使用密码的目的不是密码本身要容易记忆,重要的是让不怀好意的人难以猜到。根据密码本身的保密程度,相隔一定时间后要进行修改。应尽量避免记录在并不安全的纸质介质上,也不要使用诸如姓名、电话号码、生日等别人容易猜到的数字。登录多个平台应使用不同的密码以保证个人信息的安全。不要在公用电脑中保存密码……
题外话少说。本文介绍的ASP随机生成的密码(来源于互联网),全部用字母组成(保密性强的密码要由数字、字母、标点符号等组成),一般只用于网站管理员临时发送给客户端作用户身份验证用。


<% 
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 
%>
<% 
’产生一个六位的密码 
StrRandomize CStr(Now) & CStr(Rnd) 
response.write GeneratePassword(6) 
%> 
<br><br>
<% 
’产生一个8位的密码 
StrRandomize CStr(Now) & CStr(Rnd) 
response.write GeneratePassword(8) 
%> 
<br><br>
<% 
’产生一个10位的密码 
StrRandomize CStr(Now) & CStr(Rnd) 
response.write GeneratePassword(10) 
%> 

 

<%
function makePassword(byVal maxLen)
Dim strNewPass
Dim whatsNext, upper, lower, intCounter
Randomize
For intCounter = 1 To maxLen
whatsNext = Int((1 - 0 + 1) * Rnd + 0)
If whatsNext = 0 Then
'character
upper = 90
lower = 65
Else
upper = 57
lower = 48
End If
strNewPass = strNewPass & Chr(Int((upper - lower + 1) * Rnd + lower))
Next
makePassword = strNewPass
end function
%>

<%=makePassword(SJM)%>    'SJM 生成密码位数

我要评论

昵称:
验证码:

最新评论

共0条 共0页 10条/页 首页 上一页 下一页 尾页
意见反馈