IT lexicon Security CSPRNG

CSPRNG Cryptographically secure pseudorandom number generator

Security På svenska → Updated: 2026-07-28

A random number generator whose next output cannot be predicted even by someone who has seen every previous one.

An ordinary PRNG like the Mersenne Twister is excellent for simulations and catastrophic for keys — a few hundred outputs are enough to reconstruct its entire internal state. A CSPRNG must also provide backtracking resistance: if the state leaks, past outputs stay secret.

Use the operating system's: getrandom(2), /dev/urandom, BCryptGenRandom, crypto.getRandomValues(). Never write your own and never seed from a timestamp — that is precisely how Debian's OpenSSL keys became guessable in 2006–2008.

← Back to the lexicon