Cryptography & Privacy

What Is CSPRNG (Cryptographically Secure PRNG)? Definition, Architecture & Defense

Quick Definition: A Cryptographically Secure Pseudo-Random Number Generator (CSPRNG) produces unpredictable random bytes seeded by operating-system hardware entropy, suitable for generating passwords, cryptographic keys, and session tokens.

How CSPRNG (Cryptographically Secure PRNG) Works in Practice

Standard programming functions like Math.random() in JavaScript or rand() in C are designed for speed and statistical distribution, not security—their internal state can be reconstructed after observing a few outputs. A CSPRNG (such as window.crypto.getRandomValues() in browsers or /dev/urandom in Linux) guarantees that seeing past outputs gives an attacker zero advantage in predicting future or past values.

Defensive Mitigation & Hardening Checklist

Never use Math.random() for passwords, reset tokens, CSRF tokens, or salts. Always use window.crypto.getRandomValues() in browsers or node:crypto in Node.js.

Hands-On Tool & Cheat Sheet


Related Security Glossary Terms