一个简单的加密/解密方法,一个简单的加密/解密方法
【 tulaoshi.com - ASP.NET 】
Private Function EncryptString(strString)Dim CharHexSet, intStringLen, strTemp, strRAW, i, intKey, intOffSetRandomize Timer
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
来源:http://www.tulaoshi.com/n/20160129/1491517.html
看过《一个简单的加密/解密方法》的人还看了以下文章 更多>>
经验教程
收藏
Photoshop简单方法打造一个美丽的花坛
飞龙岭龙飞
Fireworks教程:一个简单LOGO的制作方法
我的青春Bu美丽
javascript实现的文字加密解密
小姐之言