Chapter 4. Random Numbers

Random numbers are important for cryptography. As we discussed in Chapter 2, computers are not very good at producing truly random data. Instead, they rely on a pseudo-random number generator (PRNG). A cryptographically strong PRNG, seeded with truly random values, is a PRNG that does a good job of spewing out unpredictable data. But if the PRNG is not cryptographically strong, or if the seed data is not random, the security of your application can be compromised.

In this chapter, I’ll talk about a cryptographically strong PRNG that was introduced in JDK 1.1, java.security.SecureRandom. The rest of the chapter discusses how to produce random seed data from keyboard events.

Get Java Cryptography now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.