Class BigIntegers

java.lang.Object
org.bouncycastle.util.BigIntegers

public final class BigIntegers extends Object
BigInteger utilities.
  • Field Details

  • Constructor Details

    • BigIntegers

      public BigIntegers()
  • Method Details

    • asUnsignedByteArray

      public static byte[] asUnsignedByteArray(BigInteger value)
      Return the passed in value as an unsigned byte array.
      Parameters:
      value - value to be converted.
      Returns:
      a byte array without a leading zero byte if present in the signed encoding.
    • asUnsignedByteArray

      public static byte[] asUnsignedByteArray(int length, BigInteger value)
      Return the passed in value as an unsigned byte array.
      Parameters:
      value - value to be converted.
      Returns:
      a byte array without a leading zero byte if present in the signed encoding.
    • createRandomInRange

      public static BigInteger createRandomInRange(BigInteger min, BigInteger max, SecureRandom random)
      Return a random BigInteger not less than 'min' and not greater than 'max'
      Parameters:
      min - the least value that may be generated
      max - the greatest value that may be generated
      random - the source of randomness
      Returns:
      a random BigInteger value in the range [min,max]
    • fromUnsignedByteArray

      public static BigInteger fromUnsignedByteArray(byte[] buf)
    • fromUnsignedByteArray

      public static BigInteger fromUnsignedByteArray(byte[] buf, int off, int length)
    • createRandomBigInteger

      public static BigInteger createRandomBigInteger(int bitLength, SecureRandom random)
      Return a positive BigInteger in the range of 0 to 2**bitLength - 1.
      Parameters:
      bitLength - maximum bit length for the generated BigInteger.
      random - a source of randomness.
      Returns:
      a positive BigInteger