日期:2009-11-26 浏览次数:20492 次
Private Function EncryptString(strString)
intKey = Round((RND * 1000000) + 1000000) '##### Key BitsizeintOffSet = Round((RND * 1000000) + 1000000) '##### KeyOffSet Bitsize
If IsNull(strString) = False ThenstrRAW = strStringintStringLen = Len(strRAW)
For i = 0 to intStringLen - 1strTemp = 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)ElseEncryptString = ""End IfEnd Function
Private Function DecryptString(strCryptString)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))
arHexCharSet = Split(strHexCrypData, Hex(intKey))
For i=0 to UBound(arHexCharSet)strRAW = strRAW & Chr(HexConv(arHexCharSet(i))/intKey)Next
DecryptString = strRAWEnd Function
Private Function HexConv(hexVar)Dim hxx, hxx_var, multiply IF hexVar <> "" THENhexVar = UCASE(hexVar)hexVar = StrReverse(hexVar)DIM hx()REDIM hx(LEN(hexVar))hxx = 0hxx_var = 0FOR hxx = 1 TO LEN(hexVar)IF multiply = "" THEN multiply = 1hx(hxx) = mid(hexVar,hxx,1)hxx_var = (get_hxno(hx(hxx)) * multiply) + hxx_varmultiply = (multiply * 16)NEXThexVar = hxx_varHexConv = hexVarEND IFEnd Function
Private Function get_hxno(ghx)If ghx = "A" Thenghx = 10ElseIf ghx = "B" Thenghx = 11ElseIf ghx = "C" Thenghx = 12ElseIf ghx = "D" Thenghx = 13ElseIf ghx = "E" Thenghx = 14ElseIf ghx = "F" Thenghx = 15End Ifget_hxno = ghxEnd Function