A simple encryptiondecryption method

xiaoxiao2021-03-05  22

Private function encryptstring (strstring) Dim Charhexset, IntStringlen, Strtemp, Strraw, I, Intkey, InToffsetrandomize Timer

INTKEY = ROUND ((RND * 1000000) 1000000) '##### Key BitsizeInToffset = Round ((RND * 1000000) 1000000)' #### kyoffset bitsize

IF isnull (strstring) = false trenstrraw = strstringintstringlen = LEN (STRRAW)

For i = 0 to INTSTRINGLEN - 1STRTEMP = Left (Strraw, 1) Strraw = Right (Strraw, Len (Straw) - 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, STRRRAWKEY, 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 (Strrawkey) 1))

Arhexcharset = split (strhexcrypdata, hex (intKey))

For i = 0 to ubound (arhexcharset) strraw = strraw & chr (HEXCONV (Arhexcharset (i)) / intKey) Next

Decryptstring = STRRRAWEND 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 FunctionPrivate 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" belove = 15nd ifget_hxno = ghxend function

转载请注明原文地址:https://www.9cbs.com/read-38962.html

New Post(0)