Interface SecureRandomService

All Known Implementing Classes:
DefaultSecureRandomService

public interface SecureRandomService
A generator for random data which is cryptographically secure, based on the same interface as SecureRandom.

Using this interface instead of using SecureRandom directly will allow implementations to provide security or performance improvements (such as dynamic re-seeding) without any changes to client code.

Implementations are required to be thread-safe.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns the next pseudorandom boolean.
    void
    nextBytes(byte[] bytes)
    Generates a user-specified number of random bytes.
    double
    Returns the next pseudorandom double.
    float
    Returns the next pseudorandom float.
    int
    Returns the next pseudorandom int.
    int
    nextInt(int n)
    Returns a pseudorandom, int value between 0 (inclusive) and the specified value (exclusive).
    long
    Returns the next pseudorandom long.
  • Method Details

    • nextBytes

      void nextBytes(byte[] bytes)
      Generates a user-specified number of random bytes.
      Parameters:
      bytes - the array to be filled in with random bytes.
      See Also:
    • nextInt

      int nextInt()
      Returns the next pseudorandom int.
      Returns:
      the next pseudorandom int.
      See Also:
    • nextInt

      int nextInt(int n)
      Returns a pseudorandom, int value between 0 (inclusive) and the specified value (exclusive).
      Parameters:
      n - the bound on the random number to be returned. Must be positive.
      Returns:
      the next pseudorandom, int value between 0 (inclusive) and n (exclusive).
      Throws:
      IllegalArgumentException - if n is not positive
      See Also:
    • nextLong

      long nextLong()
      Returns the next pseudorandom long.
      Returns:
      the next pseudorandom long.
      See Also:
    • nextBoolean

      boolean nextBoolean()
      Returns the next pseudorandom boolean.
      Returns:
      the next pseudorandom boolean.
      See Also:
    • nextFloat

      float nextFloat()
      Returns the next pseudorandom float.
      Returns:
      the next pseudorandom float.
      See Also:
    • nextDouble

      double nextDouble()
      Returns the next pseudorandom double.
      Returns:
      the next pseudorandom double.
      See Also: