Search code examples
javarandomprng

Seeding a secure random number in java


Will two java.security.SecureRandom instances which are seeded with the same value initially give the same sequence of random numbers?

I am asking this because I want the same sequence of random numbers in both the client and the server. What if both of them are using the same seed value. Will the sequence be the same, or is there any way that the sequence can be made the same?


Solution

  • From the API docs:

    If two instances of Random are created with the same seed, and the same sequence of method calls is made for each, they will generate and return identical sequences of numbers.