public final class BigIntegers extends Object
Modifier and Type | Field and Description |
---|---|
static BigInteger |
ONE |
static BigInteger |
TWO |
static BigInteger |
ZERO |
Constructor and Description |
---|
BigIntegers() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
asUnsignedByteArray(BigInteger value)
Return the passed in value as an unsigned byte array.
|
static void |
asUnsignedByteArray(BigInteger value,
byte[] buf,
int off,
int len)
Write the passed in value as unsigned bytes to the specified buffer range, padded with
leading zeros as necessary.
|
static byte[] |
asUnsignedByteArray(int length,
BigInteger value)
Return the passed in value as an unsigned byte array of the specified length, padded with
leading zeros as necessary..
|
static BigInteger |
createRandomBigInteger(int bitLength,
SecureRandom random)
Return a positive BigInteger in the range of 0 to 2**bitLength - 1.
|
static BigInteger |
createRandomInRange(BigInteger min,
BigInteger max,
SecureRandom random)
Return a random BigInteger not less than 'min' and not greater than 'max'
|
static BigInteger |
createRandomPrime(int bitLength,
int certainty,
SecureRandom random)
Return a prime number candidate of the specified bit length.
|
static BigInteger |
fromUnsignedByteArray(byte[] buf) |
static BigInteger |
fromUnsignedByteArray(byte[] buf,
int off,
int length) |
static int |
getUnsignedByteLength(BigInteger n) |
static int |
intValueExact(BigInteger x) |
static long |
longValueExact(BigInteger x) |
static BigInteger |
modOddInverse(BigInteger M,
BigInteger X) |
static BigInteger |
modOddInverseVar(BigInteger M,
BigInteger X) |
public static final BigInteger ZERO
public static final BigInteger ONE
public static final BigInteger TWO
public static byte[] asUnsignedByteArray(BigInteger value)
value
- the value to be converted.public static byte[] asUnsignedByteArray(int length, BigInteger value)
length
- the fixed length of the resultvalue
- the value to be converted.public static void asUnsignedByteArray(BigInteger value, byte[] buf, int off, int len)
value
- the value to be converted.buf
- the buffer to which the value is written.off
- the start offset in array buf
at which the data is written.len
- the fixed length of data written (possibly padded with leading zeros).public static BigInteger createRandomInRange(BigInteger min, BigInteger max, SecureRandom random)
min
- the least value that may be generatedmax
- the greatest value that may be generatedrandom
- the source of randomnesspublic static BigInteger fromUnsignedByteArray(byte[] buf)
public static BigInteger fromUnsignedByteArray(byte[] buf, int off, int length)
public static int intValueExact(BigInteger x)
public static long longValueExact(BigInteger x)
public static BigInteger modOddInverse(BigInteger M, BigInteger X)
public static BigInteger modOddInverseVar(BigInteger M, BigInteger X)
public static int getUnsignedByteLength(BigInteger n)
public static BigInteger createRandomBigInteger(int bitLength, SecureRandom random)
bitLength
- maximum bit length for the generated BigInteger.random
- a source of randomness.public static BigInteger createRandomPrime(int bitLength, int certainty, SecureRandom random)
bitLength
- bit length for the generated BigInteger.random
- a source of randomness.Copyright © 2021 BouncyCastle.org. All rights reserved.