asp如何做一个密码“生成器”?

时间:2010-07-12 18:51:00 

如何做一个密码“生成器”?
randompassword.asp

<% 
Dim i, intNum, intUpper, intLower, intRand, strPartPass, genPassword 
genPassword = \"\" 
Randomize 
'用Randomize生成随机种子
For i = 1 to 7 
' 循环7次,即创建7位随机密码
intNum = Int(10 * Rnd + 48) 
' 0-9的ASCII码范围是48-57
intUpper = Int(26 * Rnd + 65)
' A-Z的ASCII码范围是65-90
intLower = Int(26 * Rnd + 97)
' a-z的ASCII码范围是97-123
intRand = Int(3 * Rnd + 1)
' 对Int(3 * Rnd + 1)取整得到intRand,会有3种结果,用select case判断当前的intRand值是1、2还是3,如果是1显示数字,是2显示大写字符,是3则显示小写字符
Select Case intRand 
Case 1 
strPartPass = Chr(intNum) 
' 用Chr方法换算到对应的ASCII值
Case 2 
strPartPass = Chr(intUpper)
Case 3 
strPartPass = Chr(intLower)
End Select 
genPassword = genPassword & strPartPass 
Next 
randomPassword = genPassword 
' 将创建的密码保存在变量randomPassword中
%> 
<%=\"请保存好,您的密码是:\" & randomPassword%>

如果要创建更多位数的密码,只要修改For i = 1 to 7就可以了,For i = 1 to n,n为密码位数。

 

标签:密码,asp,随机
0
投稿

猜你喜欢

  • oracle 多个字符替换实现

    2009-10-23 17:50:00
  • Asp测试网速代码(带进度条)

    2007-11-12 13:09:00
  • eWebEditor在线HTML编辑助手下载及安装使用说明

    2008-10-11 13:58:00
  • 用ASP读取/写入UTF-8编码格式的文件

    2007-08-20 09:29:00
  • chr(9)、chr(10)、chr(13)、chr(32)与特殊空格

    2009-07-03 15:26:00
  • ASP操作XML文件的完整实例

    2007-09-26 12:05:00
  • 如何才能保护好我们的SQL Server数据库

    2009-01-08 13:37:00
  • ASP实现类似Java中的Linked HashMap类

    2010-04-03 20:49:00
  • 学习CSS布局心得

    2007-05-11 16:50:00
  • 《JavaScript语言精粹》

    2009-04-03 11:27:00
  • 优化次数过多的循环

    2009-11-12 12:35:00
  • jQuerify书签

    2008-06-16 12:16:00
  • asp如何显示自定义随机信息?

    2010-06-08 09:39:00
  • 关闭窗口时保存数据的办法

    2009-02-19 13:39:00
  • 用自定义html标签让IE支持html5新增元素

    2011-03-17 16:10:00
  • SQL集合函数中case when then 使用技巧

    2011-09-30 11:54:59
  • 如何用ASP创建日志文件

    2008-03-10 17:27:00
  • OracleEXP和IMP用法和介绍

    2010-07-28 13:18:00
  • 不成熟的标准化是我们唯一惧怕的

    2008-08-15 18:55:00
  • 正在研究XMLHTTP如何正确传送大于7F(127)的二进制数据

    2008-09-13 18:41:00
  • asp之家 网络编程 m.aspxhome.com