当前位置: 网学 > 编程文档 > ASP > 正文

asp下的一个很简单的验证码程序第1/3页

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/16

【编者按】:网学网ASP为您提供asp下的一个很简单的验证码程序第1/3页参考,解决您在asp下的一个很简单的验证码程序第1/3页学习中工作中的难题,参考学习

程序共三个

我的调用方式 <script language="javascript" src="/verify/num.asp"></script>
验证方式 if trim(Loginnum)<>trim(session("Loginnum")) then
Response.Write Error("验证码错误!")
Response.End
end if


num.asp

<%
''### To encrypt/decrypt include this code in your page
''### strMyEncryptedString = EncryptString(strString)
''### strMyDecryptedString = DeCryptString(strMyEncryptedString)
''### You are free to use this code as long as credits remain in place
''### also if you improve this code let me know.

Private Function EncryptString(strString)
''####################################################################
''### Crypt Function ? 2001 by Slavic Kozyuk grindkore@yahoo.com ###
''### Arguments: strString <--- String you wish to encrypt ###
''### Output: Encrypted HEX string ###
''####################################################################

Dim CharHexSet, intStringLen, strTemp, strRAW, I, intKey, intOffSet
Randomize Timer

intKey = Round((RND * 1000000) + 1000000) ''##### Key Bitsize
intOffSet = Round((RND * 1000000) + 1000000) ''##### KeyOffSet Bitsize

If IsNull(strString) = False Then
strRAW = strString
intStringLen = Len(strRAW)

For i = 0 to intStringLen - 1
strTemp = Left(strRAW, 1)
strRAW = Right(strRAW, Len(strRAW) - 1)
CharHexSet = CharHexSet & Hex(Asc(strTemp) * intKey)& Hex(intKey)
Next

EncryptString = CharHexSet & "|" & Hex(intOffSet + intKey) & "|" & Hex(intOffSet)
Else
EncryptString = ""
End If
End Function



Private Function DeCryptString(strCryptString)
''####################################################################
''### Crypt Function ? 2001 by Slavic Kozyuk grindkore@yahoo.com ###
''### Arguments: Encrypted HEX stringt ###
''### Output: Decrypted ASCII string ###
''####################################################################
''### Note this function uses HexConv() and get_hxno() functions ###
''### so make sure they are not removed ###
''####################################################################

Dim strRAW, arHexCharSet, I, intKey, intOffSet, strRawKey, strHexCrypData


strRawKey = Right(strCryptString, Len(strCryptString) - InStr(strCryptString, "|"))
intOffSet = Right(strRawKey, Len(strRawKey) - InStr(strRawKey,"|"))
intKey = HexConv(Left(strRawKey, InStr(strRawKey, "|") - 1)) - HexConv(intOffSet)
strHexCrypData = Left(strCryptString, Len(strCryptString) - (Len(strRawKey) + 1))


arHexCharSet = Split(strHexCrypData, Hex(intKey))

For i=0 to Ubound(arHexCharSet)
strRAW = strRAW & Chr(HexConv(arHexCharSet(i))/intKey)
Next

DeCryptString = strRAW
End Function


Private Function HexConv(hexVar)
Dim hxx, hxx_var, multiply
IF hexVar <> "" THEN
hexVar = UCASE(hexVar)
hexVar = StrReverse(hexVar)
DIM hx()
REDIM hx(LEN(hexVar))
hxx = 0
hxx_var = 0
FOR hxx = 1 TO LEN(hexVar)
IF multiply = "" THEN multiply = 1
hx(hxx) = mid(hexVar,hxx,1)
hxx_var = (get_hxno(hx(hxx)) * multiply) + hxx_var
multiply = (multiply * 16)

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号