RC4 Encryption principle

Source: Internet
Author: User

Encryption principle:
1, through the key scheduling algorithm KSA initialization state vector s (S is a random number generator, called S-box)
2, and then the pseudo-random number generation algorithm Prga to get the key stream keystream
3, the key stream keystream with the plaintext XOR operation obtains ciphertext, decrypts the key stream and the ciphertext XOR

1. KSA

RC4 first uses the key scheduling algorithm (KSA) to initialize and replace byte array s (s-box) of size 256. Use a key when replacing. Its key length generally takes 5~16 bytes, that is, 40~128 bit, can also be longer, usually no more than 256 bits. First initialize the array s with 0~255 and then replace it with the key.

2. Prga

The input key is no longer used after the initialization of the array s is complete. The key stream is generated from s[0]~s[255], for each s[i], according to the current S value, the s[i] with another byte in the S is replaced. When s[255] completes the conversion, the operation continues to execute repeatedly.

The obtained sub-cipher K is used for XOR operation with plaintext, and the decryption process is identical.

RC4 Encryption principle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.