密码问题

wuzhiwuwei 2004-10-28 07:30:26
想对输入的密码的复杂程度做个限制,比如至少6位,必须含有数字、大、小写字母、至少一两个特殊字符,怎么才能做到呢
...全文
89 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
unkowme 2004-10-28
  • 打赏
  • 举报
回复
用正则表达式!
是是非非 2004-10-28
  • 打赏
  • 举报
回复
GetComplicacyOfPassword("")=0
GetComplicacyOfPassword("asdadajkhdask")=1
GetComplicacyOfPassword("asdadAskhdDsk")=2
GetComplicacyOfPassword("asdADAjk1235k")=3
GetComplicacyOfPassword("aSDADa#12ka@k")=4
GetComplicacyOfPassword("asdadaj你好sk")=101
GetComplicacyOfPassword("asdadaj你好sk")实际为2
是是非非 2004-10-28
  • 打赏
  • 举报
回复
<% @LANGUAGE="VBSCRIPT" CODEPAGE="936" %>
<%
' 返回0:输入字符串为空
' 返回1~4:复杂度为1~4
' 返回大于4:包含有汉字或者键盘上无法输入的字符,减去100再加一就是实际的复杂度
Public Function GetComplicacyOfPassword(strPwd)
If Len(strPwd)=0 Then
GetComplicacyOfPassword=0
Exit Function
End If
Dim cUpperChar,cLowerChar,cNumeric,cSpecialChar,cOther
Dim iCnt,ascTmp
cUpperChar=0
cLowerChar=0
cNumeric=0
cSpecialChar=0
cOther=0
For iCnt=1 To Len(strPwd)
ascTmp=Asc(Mid(strPwd,iCnt,1))
If ascTmp>0 And ascTmp<127 Then
If ascTmp>=Asc("A") And ascTmp<=Asc("Z") Then 'A ~ Z
cUpperChar=1
ElseIf ascTmp>=Asc("a") And ascTmp<=Asc("z") Then 'a ~ z
cLowerChar=1
ElseIf ascTmp>=Asc("0") And ascTmp<=Asc("9") Then '0 ~ 9
cNumeric=1
ElseIf ascTmp>=33 And ascTmp<=47 Then '! ~ /
cSpecialChar=1
ElseIf ascTmp>=58 And ascTmp<=64 Then ': ~ @
cSpecialChar=1
ElseIf ascTmp>=91 And ascTmp<=96 Then '[ ~ `
cSpecialChar=1
ElseIf ascTmp>=123 And ascTmp<=126 Then '{ ~ ~
cSpecialChar=1
End If
Else
cOther=1 '汉字或者键盘上无法输入的字符
End If
Next
GetComplicacyOfPassword=cUpperChar+cLowerChar+cNumeric+cSpecialChar+cOther*100
End Function
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="pragma" content="no-cache" />
<style type="text/css">
<!--
-->
</style>
<script language="JavaScript">
<!--
-->
</script>
<title></title>
</head>
<body>
GetComplicacyOfPassword("")=<%=GetComplicacyOfPassword("")%><br />
GetComplicacyOfPassword("asdadajkhdask")=<%=GetComplicacyOfPassword("asdadajkhdask")%><br />
GetComplicacyOfPassword("asdadAskhdDsk")=<%=GetComplicacyOfPassword("asdadAskhdDsk")%><br />
GetComplicacyOfPassword("asdADAjk1235k")=<%=GetComplicacyOfPassword("asdADAjk1235k")%><br />
GetComplicacyOfPassword("aSDADa#12ka@k")=<%=GetComplicacyOfPassword("aSDADa#12ka@k")%><br />
GetComplicacyOfPassword("asdadaj你好sk")=<%=GetComplicacyOfPassword("asdadaj你好sk")%><br />
GetComplicacyOfPassword("asdadaj你好sk")实际为<%=GetComplicacyOfPassword("asdadaj你好sk")-99%><br />
</body>
</html>

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧