Page 1/3 of a simple verification code program under ASP

Source: Internet
Author: User

Master Program Three

My call method <script language = "JavaScript" src = "/verify/num. asp"> </SCRIPT>
Verification Method if trim (loginnum) <> trim (Session ("loginnum") then
Response. Write error ("Verification code error! ")
Response. End
End if

Num. 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, effecffset
Randomize Timer

Intkey = round (RND * 1000000) + 1000000) '##### key bitsize
Effecffset = 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 (effecffset + intkey) & "|" & hex (effecffset)
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, effecffset, strrawkey, strhexcrypdata

Strrawkey = right (strcryptstring, Len (strcryptstring)-instr (strcryptstring, "| "))
Export ffset = right (strrawkey, Len (strrawkey)-instr (strrawkey, "| "))
Intkey = hexconv (left (strrawkey, instr (strrawkey, "|")-1)-hexconv (effecffset)
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
Num = int (7999 * RND + 2000) 'counter value
Num2 = encryptstring (Num)
Session ("loginnum") = num
%>
Document. Write (" '> ")' indicates the path of the image to be called.

Count. asp

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.