RC4加密原理

RC4 Encryption Principle

 

The RC4 encryption algorithm is stream cipher, which can use variable length keys. The algorithm was developed in 1987 by Ron Rivest, for RSA Data Security, and was a propriety algorithm until 1994.

In the algorithm the keystream is completely independent of the plaintext used. An 8 * 8 S-Box (S0 S255), each of the entries is a permutation of the numbers 0 to 255, and the permutation is a function of the variable length key. There are two counters i, and j, both initialised to 0 used in the algorithm.

The S-Box is easily generated, using the following:

Fill S1 to S255 linearly (i.e. S0 = 0; S1 = 1 ... S255 = 255)

Another 256 byte array is then filled with the key, the key is repeated as necessary to fill the entire array.

The index j is then set to 0

for (i = 0 to i = 255)
     j = (j + Si + ki) MOD 256
    Swap Si and Sj
fi

The following is used to generate a random byte:

i = (i + 1) MOD 256
j = (j + Si) MOD 256
Swap Si and Sj
t = (Si + Sj) MOD 256
K = St

K is the XORed with the plaintext to produce the ciphertext, or the ciphertext to produce the plaintext.

RSA claims that the algorithm is immune to differential and linear cryptanalysis. The algorithm can also be changed from the 8-bit used above to 16-bit by using a 16 * 16 S-Box, and a 16-bit word. The initial set-up would need to be repeated 65,536 times to keep with the design, but it should be faster.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值