I need to generate cryptographically secure, random and unique strings each of which will be used as an access token actually. For this purpose, I plan to use Java's SecureRandom
class. But, I'm not sure that SecureRandom guarantees the uniqueness. In other words, does SecureRandom produces a different value on each time of the generation?
It seems like creating the instance with a seed
value (i.e. new SecureRandom(byte[] seed)
) may work. But, I'm not sure of that. Moreover, this answer states that the seed is neither safe nor portable. Does seed value serve my purpose?
If you have suggestions other than SecureRandom I want to hear them also.