What is Cryptographically Secure PRNG?
A pseudorandom number generator with properties that make it cryptographically unpredictable and suitable for generating encryption keys, session tokens, and passwords.
The Two Critical Requirements of a CSPRNG
To be classified as cryptographically secure, a PRNG must satisfy two conditions: The Next-Bit Test (given the first k bits of a sequence, an attacker cannot predict the next bit with probability greater than 50%), and State Compromise Resistance (if internal generator state is compromised, previous output bits cannot be deduced).
Standard functions like JavaScript's `Math.random()` fail both tests because they use simple linear or xorshift algorithms designed solely for speed and statistical uniformity.
Kernel Entropy Harvesting in Web Crypto
The browser Web Crypto API (`window.crypto.getRandomValues()`) taps directly into operating system entropy pools (such as `/dev/urandom` on Linux/macOS or `BCryptGenRandom` on Windows).
These pools harvest unpredictable physical hardware noise: keystroke timings, mouse trajectory jitter, thermal sensor fluctuations, and disk I/O interrupt cycles.
DocSwift relies exclusively on Web Crypto CSPRNG primitives to generate encryption passphrases, AES initialization vectors, and cryptographic salts.
Key Advantages & Impact
- Unpredictable by modern supercomputers and quantum cryptanalysis
- Essential foundational building block for SSL/TLS handshakes, AES keys, and salt generation
- Directly accessible in client-side web browsers with zero external library overhead
Common Misconceptions vs Reality
Experience This Technology in DocSwift Tools
Frequently Asked Questions
How do I generate a secure random number in client-side JavaScript?
Use `window.crypto.getRandomValues(new Uint32Array(1))[0]` rather than `Math.random()`.