Verification code procedures and principles, see the need for a lot of people, posted out, hope to enter the essence for future reference

Source: Internet
Author: User
Tags crypt reference
Program | essence | 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))



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.