For cryptographic purposes, it is necessary that the stream be "computationally indistinguishable from uniformly random bits." “Computationally” means that it should not be truly random, just to make it appear to someone without access to God, his own computer.
In practice, this means that the system must first assemble a sequence of n truly random bits. n must be large enough to prevent an exhaustive search, i.e. it is impractical to use all 2 ^ n-combinations of n bits. This is achieved in relation to today's technology if n is greater than 90 or so, but cryptographers just love the powers of the two, so it’s customary to use n = 128.
These n random bits are obtained by collecting "physical events" which should be unpredictable as far as physics is concerned. Usually time is used: the processor has a cycle counter that is updated several billion times per second, and some events occur with an inevitable amount of jitter (incoming network packets, mouse movements, keystrokes ...). The system encodes these events and then “compresses” them using a cryptographically secure hash function such as SHA-256 (the output is then truncated to get our n bits). It is important here that the coding of physical events has sufficient entropy: roughly speaking, the events mentioned could together take at least 2 ^ n combinations. A hash function, by its definition, should concentrate well on the concentration of this entropy in an n-bit string.
Once we have n bits, we use PRNG (pseudo random number generator) to extract as many bits as possible. It is said that PRNG is cryptographically secure if, assuming that it works on a rather narrow unknown n-bit key, its output is computationally indistinguishable from uniformly random bits. In the 90s, the RC4 was a popular choice, which is very easy to implement and pretty fast. However, it turned out that he has measurable prejudices, i.e. He was not as indistinguishable as he had originally desired. The eSTREAM project was to collect new projects for PRNG (actually stream ciphers, since most stream ciphers consist of PRNG, whose output is XORed to encrypt the data), document them and promote the analysis with cryptographs. The eSTREAM portfolio contains seven PRNG projects that were considered quite safe (i.e., they resisted the analysis, and cryptographers, as a rule, well understood why they resisted). Among them, four are "software optimized." The good news is that although these new PRNGs seem much more secure than RC4, they are also noticeably faster (we are talking about hundreds of megabytes per second, here). Three of them are “free for any use” and source code is provided.
From a design point of view, PRNG reuses many block cipher elements. The same concepts of avalanche and diffusion of bits into a wide internal state are used. Alternatively, a decent PRNG can be built from a block cipher: just use the n-bit sequence as the key in the block cipher and encode the sequential counter values (expressed as a m-bit sequence if the block cipher uses m-bits). This creates a pseudo-random bitstream, which is computationally indistinguishable from random, as long as the block cipher is safe and the resulting stream is no more than m * 2 ^ (m / 2) bits (with m = 128, this means about 300 billion gigabytes, which is enough for most purposes). This use is known as counter mode (CTR) .
Typically, a block cipher in CTR mode does not work as fast as a dedicated stream cipher (the point of stream encryption is that, losing the flexibility of the block cipher, higher performance is expected). However, if you have one of the latest Intel processors with AES-NI instructions (which are basically hardware AES implementations integrated into the CPU), then AES with CTR mode will give you unrivaled speed (several gigabytes per second).