SecureRandom generateSeed() method in Java with Examples
The generateSeed() method of java.security.SecureRandom class is used to return the given number of seed bytes, computed using the seed generation algorithm that this class uses to seed itself. This call may be used to seed other random number generators.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
public byte generateSeed(int numBytes)
Parameters: This method takes the number of seed bytes to generate as parameter.
Return Value: This method returns the generated seed bytes.
Below are the examples to illustrate the generateSeed() method:
- This program will not run on online IDE.
- Every time Secure Random class will generate random output.
[24, -16, -12, 25, -3, 66, -90, 103]
Trying to get the instance from an unknown source Exception thrown : java.security.NoSuchAlgorithmException: TAJMAHAL SecureRandom not available