欢迎光临
我们一直在努力

随机产生用户密码(good)

建站超值云服务器,限时71元/月

  说明:通过随机产生密码,然后将密码email给注册用户,你可以确认用户的email填写是否正确。自动产生的密码往往安全性更高,同时,你可以过滤那些无效的用户。

  把下面的代码保存为random.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

%>

  然后在你的目标程序中这样调用上面的代码,就可以实现密码的自动生成:(仅仅是一个例子,你可以把他们粘贴到一个test.asp的文件中,然后运行test.asp)

<!–include file="random.asp" –>

<%

产生一个六位的密码

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)

%>

<br><br>

<%

产生1000个密码

dim t, t2

  for t = 1 to 500

  for t2 = 1 to 661

  strrandomize cstr(now) & cstr(rnd)

  next

  strrandomize cstr(now) & cstr(rnd)

  response.write generatepassword(6)

  response.write "<br>"

next

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 随机产生用户密码(good)
分享到: 更多 (0)