1
2'### To encrypt/decrypt include this code in your page
3'### strMyEncryptedString = EncryptString(strString)
4'### strMyDecryptedString = DeCryptString(strMyEncryptedString)
5'### You are free to use this code as long as credits remain in place
6'### also if you improve this code let me know.
7
8Private Function EncryptString(strString)
9'####################################################################
10'### Crypt Function (C) 2001 by Slavic Kozyuk [email protected] ###
11'### Arguments: strString <\--- String you wish to encrypt ###
12'### Output: Encrypted HEX string ###
13'####################################################################
14
15Dim CharHexSet, intStringLen, strTemp, strRAW, i, intKey, intOffSet
16Randomize Timer
17
18intKey = Round((RND * 1000000) + 1000000) '##### Key Bitsize
19intOffSet = Round((RND * 1000000) + 1000000) '##### KeyOffSet Bitsize
20
21If IsNull(strString) = False Then
22strRAW = strString
23intStringLen = Len(strRAW)
24
25For i = 0 to intStringLen - 1
26strTemp = Left(strRAW, 1)
27strRAW = Right(strRAW, Len(strRAW) - 1)
28CharHexSet = CharHexSet & Hex(Asc(strTemp) * intKey)
29& Hex(intKey)
30Next
31
32EncryptString = CharHexSet & "|" & Hex(intOffSet + intKey) & "|" & Hex(intOffSet)
33Else
34EncryptString = ""
35End If
36End Function
37
38
39
40
41Private Function DeCryptString(strCryptString)
42'####################################################################
43'### Crypt Function (C) 2001 by Slavic Kozyuk [email protected] ###
44'### Arguments: Encrypted HEX stringt ###
45'### Output: Decrypted ASCII string ###
46'####################################################################
47'### Note this function uses HexConv() and get_hxno() functions ###
48'### so make sure they are not removed
49###
50'####################################################################
51
52Dim strRAW, arHexCharSet, i, intKey, intOffSet, strRawKey, strHexCrypData
53
54
55strRawKey = Right(strCryptString, Len(strCryptString) - InStr(strCryptString, "|"))
56intOffSet = Right(strRawKey, Len(strRawKey) - InStr(strRawKey,"|"))
57intKey = HexConv(Left(strRawKey, InStr(strRawKey, "|") - 1)) - HexConv(intOffSet)
58strHexCrypData = Left(strCryptString, Len(strCryptString) - (Len(strRawKey) + 1))
59
60
61arHexCharSet = Split(strHexCrypData, Hex(intKey))
62
63For i=0 to UBound(arHexCharSet)
64strRAW = strRAW & Chr(HexConv(arHexCharSet(i))/intKey)
65Next
66
67DeCryptString = strRAW
68End Function
69
70
71
72Private Function HexConv(hexVar)
73Dim hxx, hxx_var, multiply
74IF hexVar <> "" THEN
75hexVar = UCASE(hexVar)
76hexVar = StrReverse(hexVar)
77DIM hx()
78REDIM hx(LEN(hexVar))
79hxx = 0
80hxx_var = 0
81FOR hxx = 1 TO LEN(hexVar)
82IF multiply = "" THEN multiply = 1
83hx(hxx) = mid(hexVar,hxx,1)
84hxx_var = (get_hxno(hx(hxx)) * multiply) + hxx_var
85multiply = (multiply * 16)
86NEXT
87hexVar = hxx_var
88HexConv = hexVar
89END IF
90End Function
91
92Private Function get_hxno(ghx)
93If ghx = "A" Then
94ghx = 10
95ElseIf ghx = "B" Then
96ghx = 11
97ElseIf ghx = "C" Then
98ghx = 12
99ElseIf ghx = "D" Then
100ghx = 13
101ElseIf ghx = "E" Then
102ghx = 14
103ElseIf ghx = "F" Then
104ghx = 15
105End If
106get_hxno = ghx
107End Function
108
109
纯猝使用VBScript来实现加密
comments powered by Disqus