台灣最大程式設計社群網站
線上人數
795
 
會員總數:246038
討論主題:189625
歡迎您免費加入會員
討論區列表 >> VB6 >> VB RC4加解密問題
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
VB RC4加解密問題
價值 : 50 QP  點閱數:1622 回應數:0
樓主

ch1056
門外漢
0 3
112 5
發送站內信

將中英文字串以RC4方式加密以Hex儲存, 在解密時一直無法完整解密成功,請幫幫忙

Public Function RC4H(inp As String, key As String) As String

Dim S(0 To 255) As Byte, K(0 To 255) As Byte, I As Long
Dim j As Long, temp As Byte, Y As Byte, t As Long, x As Long
Dim Outp As String

For I = 0 To 255
S(I) = I
Next

j = 1
For I = 0 To 255
If j > Len(key) Then j = 1
K(I) = Asc(Mid(key, j, 1))
j = j + 1
Next I

j = 0
For I = 0 To 255
j = (j + S(I) + K(I)) Mod 256
temp = S(I)
S(I) = S(j)
S(j) = temp
Next I

I = 0
j = 0
For x = 1 To Len(inp)
I = (I + 1) Mod 256
j = (j + S(I)) Mod 256
temp = S(I)
S(I) = S(j)
S(j) = temp
t = (S(I) + (S(j) Mod 256)) Mod 256
Y = S(t)
Outp = Outp & Hex(Asc(Mid(inp, x, 1)) Xor Y)

Next
RC4H = Outp

搜尋相關Tags的文章: [ RC4 ] , [ 加解密 ] ,
本篇文章發表於2008-06-18 23:00
目前尚無任何回覆
   

回覆
如要回應,請先登入.