www.BCZJ.com【编程之家】 >> ASP高级 >> 验证码的程序及原理

验证码的程序及原理

www.BCZJ.com【编程之家】 www.bczj.com admin 2007-2-22 0:23:09

一共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 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

责任编辑: 参与评论
【编程之家】版权所有 www.bczj.com 沪ICP备06025676号 QQ:382611662
Powered By: 上海驰志网络 3.0 Beta