"Classic Cryptography and Modern Cryptography" book excerpt:
A simple "stream cipher " requires a " random" " bits stream" as a "key". Ciphertext can be generated by the XOR logic operation of the plaintext with this "random key Stream" . PlainText can be restored by XOR logic with the same "random key Stream" .
To implement the XOR logic operation is simple, it is a fast and effective method of encryption when used as a bit-level. The only problem is that you must resolve how to generate a "random key stream." This is a problem because the "key stream" must be "random", and legitimate users can easily regenerate the key stream. If the key stream is a repeating bit sequence, it is easy to remember, but not very secure. A random sequence of bits as long as a clear text is difficult to remember. So this is a dilemma, how to generate a "random" bit sequence as a "key stream" that requires ease of use, but not too short to be unsafe.
Solve the key problem of stream cryptography: Develop a "random bit generator" that generates a key stream based on a short key. The generator is used to generate the key stream, and the user simply remembers how to start the generator.
One problem with designing LFSR for generating random bits is that for a given LFSR, you can generate the longest number of non-repeating sequence bits.
RC4:
The size of the RC4 varies according to the value of the parameter n . RC4 can implement a "secret internal state", for n digits, there are n=2^n kinds of possible, usually n=8. RC4 can generate a total of 256 elements of the array S. Each output of the RC4 is a random element in the array s. To achieve this, two processes are required: One is the "Key Scheduling algorithm" (key-scheduling Algorithm,ksa), which is used to set the initial arrangement of S, and one is the pseudo-random generation algorithm (pseudo Random-generation Algorithm,prga), used to select random elements and modify the original sort order of S.
Stream encryption method