%26lt;%
'### 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 %26lt;--- String you 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 %26amp; Hex(Asc(strTemp) * intKey)
%26amp; Hex(intKey)
Next
EncryptString = CharHexSet %26amp; %26quot;|%26quot; %26amp; Hex(intOffSet + intKey) %26amp; %26quot;|%26quot; %26amp; Hex(intOffSet)
Else
EncryptString = %26quot;%26quot;
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, %26quot;|%26quot;))
intOffSet = Right(strRawKey, Len(strRawKey) - InStr(strRawKey,%26quot;|%26quot;))
intKey = HexConv(Left(strRawKey, InStr(strRawKey, %26quot;|%26quot;) - 1)) - HexConv(intOffSet)
strHexCrypData = Left(strCryptString, Len(strCryptString) - (Len(strRawKey) + 1))
arHexCharSet = Split(strHexCrypData, Hex(intKey))
For i=0 to UBound(arHexCharSet)
strRAW = strRAW %26amp; Chr(HexConv(arHexCharSet(i))/intKey)
Next
DeCryptString = strRAW
End Function
Private Function HexConv(hexVar)
Dim hxx, hxx_var, multiply
IF hexVar %26lt;%26gt; %26quot;%26quot; 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 = %26quot;%26quot; 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 = %26quot;A%26quot; Then
ghx = 10
ElseIf ghx = %26quot;B%26quot; Then
ghx = 11
ElseIf ghx = %26quot;C%26quot; Then
ghx = 12
ElseIf ghx = %26quot;D%26quot; Then
ghx = 13
ElseIf ghx = %26quot;E%26quot; Then
ghx = 14
ElseIf ghx = %26quot;F%26quot; Then
ghx = 15
End If
get_hxno = ghx
End Function
%%26gt;
纯猝使用VBScript来实现加密
2001-05-23 10:35:42 作者
相关文章
- · 用VBScript制作活动主页
- · VBScript变量
- · VBScript数据类型
- · 关于VBScript与
- · 利用VBScript实现倒计时
- · vbscript错误代码及对应解释大全
- · Microsoft VBscript运行时错误'800a000d'的解决方案
- · asp中vbscript访问xml文件
- · 使用VBScript操作Html复选框(CheckBox)控件
- · 纯猝使用VBScript来实现加密
- · 运用asp结合vbscript模拟股票滚屏
- · 一个在vbscript中读取cookie的程序函数
- · 用vbscript判断email地址的合法性
- · vbscript和javascript互相调用
- · 纯ASP(VBscript)写的全球IP地址搜索程序
- · 在ASP页里面注册DLL的VBScript CLASS
- · VBScript与JScript谁怕谁(6)
- · VBScript与JScript谁怕谁(5)
- · VBScript与JScript谁怕谁(4)
- · VBScript与JScript谁怕谁(3)
