标题:请问RC4加密算法是单向还是双向的?大家看一下。
只看楼主
cime63
Rank: 1
等 级:新手上路
帖 子:167
专家分:0
注 册:2004-8-9
 问题点数:0 回复次数:1 
请问RC4加密算法是单向还是双向的?大家看一下。

RC4经典加密算法VB版本代码 Public Sub main() Dim key As String For i = 1 To 16 Randomize key = key & Chr(Rnd * 255) Next i MsgBox RC4(RC4("Welcome To Plindge Studio!", key), key) End Sub Public Function RC4(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 & Chr(Asc(Mid(inp, x, 1)) Xor Y) Next RC4 = Outp End Function 是不是还有加密密钥key?

搜索更多相关主题的帖子: 算法 
2004-09-09 10:49
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
得分:0 

MsgBox RC4(RC4("Welcome To Plindge Studio!", key), key)

这句话好像就是说它可以用密钥还原

天津网站建设 http://www./
2004-09-10 23:26



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-5143-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.093541 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved