Mobile Network pioneer
Four pages in total: form. asp; chk. asp; num. asp; count. asp
Get a number. Encryption!
The decrypted image is converted into an XBM image.
Judging by session
Form. 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 (C) 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 (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, 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 ("pwdt") = num
%>
<Form action = "chk. asp" method = post>
Enter the verification 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: it should be: <% = session ("pwdt") %>, But you entered: <% = request. form ("pwds") %>
<%
Else
%>
Entered correctly
<% End if %>
Count. asp
<! -- # Include file = "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 (C) 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 (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, 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
%>
<%
Dim Image
Dim Width, Height
Dim num
Dim digtal
Dim Length
Dim sort
Length = 4' custom counter Length
Redim sort (Length)
Num = cint (DeCryptString (request. querystring ("sksid ")))
Digital = ""
For I = 1 To Length-Len (num) 'fill in 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) 'image Width
Height = 10' the Height of the image, which is a fixed value in this example.
Response. ContentType = "image/x-xbitmap"
Hc = chr (13) & 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"
%>