两个ASP随机生成[a-z,A-Z,0-9]的函数
<%
function fRndStr(num)
if isNumeric(num)=false then exit function else num=int(num)
dim i, j
dim rndStr(61)
for j=0 to 9:rndStr(j)=cStr(j):next
j=10:for i=65 to 90:rndStr(j)=chr(i):j=j+1:next
j=36:for i=97 to 122:rndStr(j)=chr(i):j=j+1:next
j=0:randomize
do until j=num:fRndStr=fRndStr+rndStr(Int((61 - 0 + 1) * Rnd + 0)):j=j+1:loop
erase rndStr
end function
Function Createpass(num)
Dim Ran,i,LengthNum
if isNumeric(num)=false then exit function else num=int(num)
Createpass=""
For i=1 To num
Randomize
Ran = CInt(Rnd * 2)
Randomize
If Ran = 0 Then
Ran = CInt(Rnd * 25) + 97
Createpass = Createpass & UCase(Chr(Ran))
ElseIf Ran = 1 Then
Ran = CInt(Rnd * 9)
Createpass = Createpass & Ran
ElseIf Ran = 2 Then
Ran = CInt(Rnd * 25) + 97
Createpass = Createpass & Chr(Ran)
End If
Next
End Function
response.write fRndStr(10)
response.write "<br/>"
response.write Createpass(10)
%>
本文出自 小古Blog,转载时请注明出处及相应链接。
本文永久链接: http://blog.chdz1.com/?post=130