当前位置: 首页 > 图文教程 > 网络编程 > ASP > 验证码的程序及原理

ASP
用asp执行DTC
利用ADODB.Stream使用浏览器下载服务器文件
应用数据库的唯一性约束并在asp中捕捉数据库的错误
用ASP编程控制在IIS建立Web站点
asp实现k线图(在线)
在ASP中用EasyMailObject组件处理Exchange邮件源代码(7)
在ASP中用EasyMailObject组件处理Exchange邮件源代码(6)
在ASP中用EasyMailObject组件处理Exchange邮件源代码(5)
在ASP中用EasyMailObject组件处理Exchange邮件源代码(4)
在ASP中用EasyMailObject组件处理Exchange邮件源代码(3)
在ASP中用EasyMailObject组件处理Exchange邮件源代码(2)
在ASP中用EasyMailObject组件处理Exchange邮件源代码(1)
用文本+ASP打造新闻发布系统。几点补充
用文本+ASP打造新闻发布系统(五)新闻修改
用文本+ASP打造新闻发布系统(四)新闻删除
用文本+ASP打造新闻发布系统(三)新闻列表显示
用文本+ASP打造新闻发布系统(二)新闻添加
ASP作的剪包锤游戏
ASP注册表项目修改
构建稳定的服务器端组件的七个步骤

ASP 中的 验证码的程序及原理


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 43 ::
收藏到网摘: n/a

       ##### 版权所有 转载请保留 谢谢合作
  ##### 部分程序取自网络
  ##### 作者:扬子
  ##### Email: [email protected]
  ##### QQ: 21112856
  ##### WebSite: www.tingfo.net
  
  
  一共4个页面:form.asp; chk.asp; num.asp; count.asp
  得到一个随即数字。加密!
  解密后成成XBM图片
  利用session 判断
  
  form.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 (C) 2001 by Slavic Kozyuk [email protected] ###
  '### 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 (C) 2001 by Slavic Kozyuk [email protected] ###
  '### 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 = U