Class RandomUtils

java.lang.Object
com.biglybt.core.util.RandomUtils

public class RandomUtils extends Object
  • Field Details

    • RANDOM

      public static final Random RANDOM
    • INSTANCE_ID

      public static final String INSTANCE_ID
    • SECURE_RANDOM

      public static final SecureRandom SECURE_RANDOM
    • LISTEN_PORT_MIN

      public static final int LISTEN_PORT_MIN
      See Also:
    • LISTEN_PORT_MAX

      public static final int LISTEN_PORT_MAX
      See Also:
  • Constructor Details

    • RandomUtils

      public RandomUtils()
  • Method Details

    • generateRandomBytes

      public static byte[] generateRandomBytes(int num_to_generate)
      Generate a random array of bytes.
      Parameters:
      num_to_generate - number of bytes to generate
      Returns:
      random byte array
    • generateRandomAlphanumerics

      public static String generateRandomAlphanumerics(int num_to_generate)
      Generate a random string of characters.
      Parameters:
      num_to_generate - number of chars to generate
      Returns:
      random char string
    • generateRandomNetworkListenPort

      public static int generateRandomNetworkListenPort()
      Generate a random port number for binding a network IP listening socket to. NOTE: Will return a valid non-privileged port number >= LISTEN_PORT_MIN and invalid input: '<'= LISTEN_PORT_MAX.
      Returns:
      random port number
    • generateRandomNetworkListenPort

      public static int generateRandomNetworkListenPort(int min_port, int max_port)
    • generateRandomPlusMinus1

      public static int generateRandomPlusMinus1()
      Generates a random +1 or -1
      Returns:
      +1 or -1
    • nextFloat

      public static float nextFloat()
    • nextBytes

      public static void nextBytes(byte[] bytes)
    • nextSecureBytes

      public static void nextSecureBytes(byte[] bytes)
    • nextSecureHash

      public static byte[] nextSecureHash()
    • nextHash

      public static byte[] nextHash()
    • nextInt

      public static int nextInt(int n)
    • nextByte

      public static byte nextByte()
    • nextInt

      public static int nextInt()
    • nextAbsoluteInt

      public static int nextAbsoluteInt()
    • nextLong

      public static long nextLong()
    • nextLong

      public static long nextLong(long n)
    • nextAbsoluteLong

      public static long nextAbsoluteLong()
    • nextSecureAbsoluteLong

      public static long nextSecureAbsoluteLong()
    • generateRandomIntUpto

      public static int generateRandomIntUpto(int max)
      Returns:
      random int between 0 and max-1. e.g. param of 10 returns 0->9
    • generateRandomIntBetween

      public static int generateRandomIntBetween(int min, int max)
      Returns:
      random int between min and max, e.g params of [5,7] returns 5,6 or 7