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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.