Input: a key (seed) of length up to 256 bytes

Output: a random byte (to be XORed with plaintext)

Initialization: Let K0, K1, K2, ... K255 be the bytes of the key, repeating the key as necessary
j = 0
for i = 0 to 255
    Si = i
for i = 0 to 255
    j = (j + Si + Ki) mod 256
    swap Si and Sj
i = 0
j = 0

Algorithm:
i = ( i + 1 ) mod 256
j = ( j + Si ) mod 256
swap Si and Sj
t = (Si + Sj ) mod 256
output St

Reference:

Applied Cryptography, by Bruce Schneier, Wiley, 1996