两个ASP随机生成[a-z,A-Z,0-9]的函数

作者: 小古 分类: 网站技术 发布时间: 2012-1-4 ė7525 次浏览 60 条评论

<%
    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

|

发表评论:

电子邮件地址不会被公开。 必填项已用*标注

Ɣ回顶部
sitemap