As I understand it, there are two main classes of Java that are able to perform pseudorandom activites: the Random
class and the SecureRandom
class. Both generate pseudorandom numbers. However, the SecureRandom
class generates cryptographically-secure numbers.
Why even use the Random
class when you can use the SecureRandom
class, which generates more unpredictable numbers? Many programmers (especially video game programmers) use solely the Random
class, but both of the classes have almost the same core method (both can generate a pseudorandom integer). Both classes can also be seeded with a long value.
My only explanation is that the Random
class operates faster than the SecureRandom
class. Is this true? If not, then why do many Java programmers prefer the Random
class than the SecureRandom
class?