asp下的一個很簡單的驗(yàn)證碼程序第2/3頁
更新時間:2007年11月24日 21:58:23 作者:
<!--#include file="numimg.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)
NEXT
hexVar = hxx_var
HexConv = hexVar
END IF
End Function
Private Function get_hxno(ghx)
If ghx = "A" Then
ghx = 10
ElseIf ghx = "B" Then
ghx = 11
ElseIf ghx = "C" Then
ghx = 12
ElseIf ghx = "D" Then
ghx = 13
ElseIf ghx = "E" Then
ghx = 14
ElseIf ghx = "F" Then
ghx = 15
End If
get_hxno = ghx
End Function
%>
<%
Dim Image
Dim Width, Height
Dim num
Dim digtal
Dim Length
Dim sort
Length = 4 '自定計數(shù)器長度
Redim sort( Length )
num=cint(DeCryptString(request.querystring("sksid")))
digital = ""
For I = 1 To Length -Len( num ) '補(bǔ)0
digital = digital & "0"
Next
For I = 1 To Len( num )
digital = digital & Mid( num, I, 1 )
Next
For I = 1 To Len( digital )
sort(I) = Mid( digital, I, 1 )
Next
Width = 8 * Len( digital ) '圖像的寬度
Height = 10 '圖像的高度,在本例中為固定值
Response.ContentType="image/x-xbitmap"
hc=chr(13) & chr(10)
Image = "#define counter_width " & Width & hc
Image = Image & "#define counter_height " & Height & hc
Image = Image & "static unsigned char counter_bits[]={" & hc
For I = 1 To Height
For J = 1 To Length
Image = Image & a(sort(J),I) & ","
Next
Next
Image = Left( Image, Len( Image ) - 1 ) '去掉最后一個逗號
Image = Image & "};" & hc
%>
<%
Response.Write Image
%>
numimg.asp
相關(guān)文章
asp之自動閉合HTML/ubb標(biāo)簽函數(shù) 附簡單注釋
在用到編輯器時,就會碰到一點(diǎn),那就是標(biāo)簽的閉合問題,這個問題非常嚴(yán)峻,因?yàn)檫@可能會導(dǎo)致網(wǎng)頁顯示的整體樣式受到破壞。2010-04-04asp下實(shí)現(xiàn)截取字符串特定部分內(nèi)容函數(shù)
asp下實(shí)現(xiàn)截取字符串特定部分內(nèi)容函數(shù)...2007-08-08asp+javascript實(shí)現(xiàn)404頁的處理轉(zhuǎn)換
用404來來解決頁面路徑的變換的方法2008-06-06ASP XMLDom在服務(wù)器端操作XML文件的主要方法和實(shí)現(xiàn)
我曾經(jīng)測試過不用數(shù)據(jù)庫,把網(wǎng)站的會員信息,商品數(shù)據(jù)信息,交易信息,網(wǎng)站定制信息全部存放在三個xml文件中,運(yùn)行結(jié)果十分正常,感覺上比數(shù)據(jù)庫快多了,不過沒有作測試,不能確定。2010-02-02asp+Access通用的自動替換數(shù)據(jù)庫中的字符串
幾年前寫的一個腳本,可以自動進(jìn)行整庫的數(shù)據(jù)替換。2008-06-06ASP讀取XML實(shí)例 優(yōu)酷專輯采集程序 雷鋒版
用asp獲取指定專題的xml文件,然后讀取xml文件的列表內(nèi)容批量讀取。2009-12-12