随机产生用户密码.asp

来自「较为详细的介绍了asp自定义的各种函数,方便asp的各种开发.」· ASP 代码 · 共 58 行

ASP
58
字号
<%
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)

%>



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?