Program and principle of ASP verification code

Source: Internet
Author: User
Tags 0xc0 define chr functions include sort split trim
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")%>
<%
Else
%>
Enter the correct
<%end if%>

Count.asp

<!--#include file= "num.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


%>


<%
Dim Image
Dim Width, Height
Dim num
Dim digtal
Dim Length
Dim sort
Length = 4 ' Custom counter Lengths

Redim Sort (Length)

Num=cint (decryptstring) (Request.QueryString ("Sksid"))
Digital = ""
For I = 1 to Length-len (num) ' supplement 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) ' breadth of the image
Height = 10 ' Elevation of image, in this case a fixed value


Response.contenttype= "Image/x-xbitmap"

HC=CHR (+) & 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) ' Remove the last comma
Image = Image & "};" & HC
%>
<%
Response.Write Image

%>

Num.asp

<%
Dim A (10,10)

A (0,1) = "0x3c" ' number 0
A (0,2) = "0x66"
A (0,3) = "0xc3"
A (0,4) = "0xc3"
A (0,5) = "0xc3"
A (0,6) = "0xc3"
A (0,7) = "0xc3"
A (0,8) = "0xc3"
A (0,9) = "0x66"
A (0,10) = "0x3c"

A (1,1) = "0x18" ' number 1
A (1,2) = "0x1c"
A (1,3) = "0x18"
A (1,4) = "0x18"
A (1,5) = "0x18"
A (1,6) = "0x18"
A (1,7) = "0x18"
A (1,8) = "0x18"
A (1,9) = "0x18"
A (0,10) = "0x7e"


A (2,1) = "0x3c" ' Number 2
A (2,2) = "0x66"
A (2,3) = "0x60"
A (2,4) = "0x60"
A (2,5) = "0x30"
A (2,6) = "0x18"
A (2,7) = "0x0c"
A (2,8) = "0x06"
A (2,9) = "0x06"
A (2,10) = "0x7e"

A (3,1) = "0x3c" ' Number 3
A (3,2) = "0x66"
A (3,3) = "0xc0"
A (3,4) = "0x60"
A (3,5) = "0x1c"
A (3,6) = "0x60"
A (3,7) = "0xc0"
A (3,8) = "0xc0"
A (3,9) = "0x66"
A (3,10) = "0x38"

A (4,1) = "0x38" ' Number 4
A (4,2) = "0x3c"
A (4,3) = "0x36"
A (4,4) = "0x33"
A (4,5) = "0x33"
A (4,6) = "0x33"
A (4,7) = "0xFF"
A (4,8) = "0x30"
A (4,9) = "0x30"
A (4,10) = "0xFE"

A (5,1) = "0xFE" ' number 5
A (5,2) = "0xFE"
A (5,3) = "0x06"
A (5,4) = "0x06"
A (5,5) = "0x3e"
A (5,6) = "0x60"
A (5,7) = "0xc0"
A (5,8) = "0xc3"
A (5,9) = "0x66"
A (5,10) = "0x3c"

A (6,1) = "0x60" ' number 6
A (6,2) = "0x30"
A (6,3) = "0x18"
A (6,4) = "0x0c"
A (6,5) = "0x3e"
A (6,6) = "0x63"
A (6,7) = "0xc3"
A (6,8) = "0xc3"
A (6,9) = "0x66"
A (6,10) = "0x3c"

A (7,1) = "0xFF" ' Number 7
A (7,2) = "0xc0"
A (7,3) = "0x60"
A (7,4) = "0x30"
A (7,5) = "0x18"
A (7,6) = "0x18"
A (7,7) = "0x18"
A (7,8) = "0x18"
A (7,9) = "0x18"
A (7,10) = "0x18"

A (8,1) = "0x3c" ' number 8
A (8,2) = "0x66"
A (8,3) = "0xc3"
A (8,4) = "0x66"
A (8,5) = "0x3c"
A (8,6) = "0x66"
A (8,7) = "0xc3"
A (8,8) = "0xc3"
A (8,9) = "0x66"
A (8,10) = "0x3c"

A (9,1) = "0x3c" ' Number 9
A (9,2) = "0x66"
A (9,3) = "0xc3"
A (9,4) = "0xc3"
A (9,5) = "0x66"
A (9,6) = "0x3c"
A (9,7) = "0x18"
A (9,8) = "0x0c"
A (9,9) = "0x06"
A (9,10) = "0x03"

%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.