欢迎光临
我们一直在努力

用ASP随机产生随机数

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

各位好今天我要告诉大家的是如何用asp产生随机数。大家都知道大多数网站注册后

提供用户名和一个随机密码,但这个密码是如何产生的,现在我就向大家来介绍一下

请看下面的例子,用户可自行增加或减少随机的字符或数量。

<%

function gen_key(digits)

create and define array

dim char_array(50)

char_array(0) = "0"

char_array(1) = "1"

char_array(2) = "2"

char_array(3) = "3"

char_array(4) = "4"

char_array(5) = "5"

char_array(6) = "6"

char_array(7) = "7"

char_array(8) = "8"

char_array(9) = "9"

char_array(10) = "a"

char_array(11) = "b"

char_array(12) = "c"

char_array(13) = "d"

char_array(14) = "e"

char_array(15) = "f"

char_array(16) = "g"

char_array(17) = "h"

char_array(18) = "i"

char_array(19) = "j"

char_array(20) = "k"

char_array(21) = "l"

char_array(22) = "m"

char_array(23) = "n"

char_array(24) = "o"

char_array(25) = "p"

char_array(26) = "q"

char_array(27) = "r"

char_array(28) = "s"

char_array(29) = "t"

char_array(30) = "u"

char_array(31) = "v"

char_array(32) = "w"

char_array(33) = "x"

char_array(34) = "y"

char_array(35) = "z"

initiate randomize method for default seeding

randomize

loop through and create the output based on the the variable passed to

the function for the length of the key.

do while len(output) < digits

num = char_array(int((35 – 0 + 1) * rnd + 0))

output = output + num

loop

set return

gen_key = output

end function

write the results to the browser, currently setting a 13 digit key

response.write "<pre>" & gen_key(13) & "</pre>" & vbcrlf

%>

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