1. 论坛系统升级为Xenforo,欢迎大家测试!
    Dismiss Notice

生成随机密码的函数

Discussion in '后端开发' started by 小叶, Dec 21, 2005.

  1. 小叶

    小叶 New Member

    Joined:
    Sep 4, 2005
    Messages:
    17,941
    Likes Received:
    33
    PHP:
    Function Createpass(LengthNum)
    'lengthNum是长度,默认是下面的16位
            Dim Ran,i
            if Not IsNumeric(LengthNum) then LengthNum=16
            Createpass=""
            For i=1 To LengthNum
                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
     
  2. Tameway

    Tameway New Member

    Joined:
    Sep 6, 2005
    Messages:
    1,286
    Likes Received:
    8
    好。。。。
     
  3. kuhanzhu

    kuhanzhu New Member

    Joined:
    Dec 10, 2005
    Messages:
    17
    Likes Received:
    0
    是ASP不是PHP,就一个
    Randomize
    Ran = CInt(Rnd * 2)
    的应用。没多大技术含量,呵。