Program | Verification Code ##### Copyright reprint please reserve thank you for your cooperation
##### part of the program is taken from the network
##### Author: Yang Zi
##### email:yangzinet@hotmail.com
##### qq:21112856
##### WebSite:www.tingfo.net
Altogether 4 pages: form.asp; chk.asp; num.asp; Count.asp
Get a random number. Encryption!
into XBM image after decryption
Using session to judge
Form.asp
<%
' ### to Encrypt/decrypt include-code in your page
' ### strmyencryptedstring = encryptstring (strstring)
' ### strmydecryptedstring = decryptstring (strmyencryptedstring)
' ### you are the free to use this code as long as credits remain into place
' ### also if you are improve this code let me know.
Private Function encryptstring (strstring)
'####################################################################
' ### Crypt Function (C) 2001 by Slavic Kozyuk grindkore@yahoo.com
' ### arguments:strstring <---String 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 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
%>
<%
Randomize
Value of num = Int (7999*rnd+2000) ' counter
num2 = encryptstring (num)
Session ("PWDT") =num
%>
<form action= "chk.asp" method=post>
Please enter the code: <input type= "text" name= "PWDs" >
<input type=submit value= submit >
</form>
Chk.asp
<%
If Trim (Request.Form ("PWDs")) <>trim (Session ("PWDT")) Then
%>
Input error: should be: <%=session ("PWDT")%>, but you enter: <%=request.form ("PWDs")%>
<%
E