A Java developer is asked to write a program that generates a sequence of random bytes for use as a cryptographic key. They search the Java API documentation for pseudorandom number generators and find two classes that could be used for the task: Random and
SecureRandom.
What are the likely differences between these two classes? Why is SecureRandom a better choice that Random?
The basic and important difference between both is SecureRandom generate more non predictable random numbers as it implements Cryptographically Secure Pseudo-Random Number Generator (CSPRNG) as compare to Random class which uses Linear Congruential Generator (LCG)
SecureRandom guarantees high reliability (non-repeatability) when generating random numbers.
Comments
Leave a comment