| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1110 人关注过本帖
标题:请问RC4加密算法是单向还是双向的?大家看一下。
取消只看楼主 加入收藏
cime63
Rank: 1
等 级:新手上路
帖 子:167
专家分:0
注 册:2004-8-9
收藏
 问题点数:0 回复次数:0 
请问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
快速回复:请问RC4加密算法是单向还是双向的?大家看一下。
数据加载中...
 
   



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

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