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.