检测生成字符串的长度
response.write(len(ixuer_rnd_str(100,1,1,1,1,1)) & "<br>")
以html编码输出到浏览器,避免含有某些特殊字符时不能正常显示
response.write(server.htmlencode(ixuer_rnd_str(100,1,1,1,1,1)))
实际应用时,可以直接调用ixuer_rnd_str(length,s1,s2,s3,s4,ln)
function ixuer_rnd_str(length,s1,s2,s3,s4,ln)
=========================================================
函数:rnd_str
功能:生成指定长度的随机字符串 ixuer studio 挑战随机字符串
参数:长度,是否大写字母,是否小写字母,是否数字,是否特殊字符,是否有自定义字符
返回:字符串
时间:2004-08-28
作者:guidy
版权:ixuer studio
=========================================================
copyright (c) 2004-2006 114xp.cn all rights reserved.
官方网站:http://www.114xp.cn
技术论坛:http://bbs.114xp.cn
电子信箱:guidy@qq.com,guidy@psysch.com
=========================================================
默认拥有15种组合方案,长度任意指定,并且字符串中不允许空格存在
如果指定了自定义字符集的话,则可以扩展到多达26种组合方案
1)大写字母2)小写字母3)数字4)特殊字符5)大写字母、小写字母6)大写字母、数字
7)大写字母、特殊字符8)大写字母、小写字母、数字9)大写字母、小写字母、特殊字符
10)大写字母、数字、特殊字符11)大写字母、小写字母、数字、特殊字符
12)小写字母、数字13)小写字母、特殊字符14)小写字母、数字、特殊字符15)数字、特殊字符
dim seed,seedary
dim seed_str,seed_str1,seed_str2,seed_str3,seed_str4,seed_strn
dim tempstr
dim i,m
seed_str1 = "a b c d e f g h i j k l m n o p q r s t u v w x y z"
seed_str2 = "a b c d e f g h i j k l m n o p q r s t u v w x y z"
seed_str3 = "0 1 2 3 4 5 6 7 8 9"
seed_str4 = "! "" # $ % & ( ) * + , – . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~"
自定义字符集合,注意要在每个自定义字符之间加空格!
seed_strn = ""
seed = ""
if s1 = 1 then
包含大写字母
seed = seed & seed_str1
end if
if s2 = 1 then
包含小写字母
seed = seed & " " & seed_str2
end if
if s3 = 1 then
包含数字
seed = seed & " " & seed_str3
end if
if s4 = 1 then
包含特殊字符
seed = seed & " " & seed_str4
end if
if ln = 1 then
包含特殊字符
seed = seed & " " & seed_strn
end if
if s1 <> 1 and s2 <> 1 and s3 <> 1 and s4 <> 1 and ln <> 1 then
如果没有指定任何包含内容,则强制全部包含
seed = seed & seed_str1 & " " & seed_str2 & " " & seed_str3 & " " & seed_str4 & " " & seed_strn
end if
建立种子数组
seedary = split(seed," ")
获取种子数组长度
m = ubound(seedary)
初始化随机字符串
tempstr = ""
do while len(tempstr) < length
randomize timer()
tempstr = tempstr & seedary(m*rnd)
loop
ixuer_rnd_str = tempstr
end function
