Class SecureRandomSeedGenerator

  • All Implemented Interfaces:
    SeedGenerator

    public class SecureRandomSeedGenerator
    extends java.lang.Object
    implements SeedGenerator

    SeedGenerator implementation that uses Java's bundled SecureRandom RNG to generate random seed data.

    The advantage of using SecureRandom for seeding but not as the primary RNG is that we can use it to seed RNGs that are much faster than SecureRandom.

    This is the only seeding strategy that is guaranteed to work on all platforms and therefore is provided as a fall-back option should none of the other provided SeedGenerator implementations be useable.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.security.SecureRandom SOURCE  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] generateSeed​(int length)
      Generate a seed value for a random number generator.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • SOURCE

        private static final java.security.SecureRandom SOURCE
    • Constructor Detail

      • SecureRandomSeedGenerator

        public SecureRandomSeedGenerator()
    • Method Detail

      • generateSeed

        public byte[] generateSeed​(int length)
                            throws SeedException
        Generate a seed value for a random number generator.
        Specified by:
        generateSeed in interface SeedGenerator
        Parameters:
        length - The length of the seed to generate (in bytes).
        Returns:
        A byte array containing the seed data.
        Throws:
        SeedException - If a seed cannot be generated for any reason.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object