A very simple Verification code program

Source: Internet
Author: User
Tags crypt decrypt include trim
Program | Verification Code Original Program
Http://vifo.vicp.net:8088/datalib/ShowTopic.asp?id=108:10:1:1

A total of three main programs

My calling way <script language= "JavaScript" src= "/verify/num.asp" ></script>
Authentication mode if trim (loginnum) <>trim (Session ("Loginnum")) Then
Response.Write Error ("Authentication code is wrong!") ")
Response.End
End If


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? 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? 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 ("Loginnum") =num
%>
document.write (" ' >") ' This is the path to the call picture

Count.asp


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



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.