BigInteger: modPow(BigInteger exponent, BigInteger m)
BigInteger modPow(BigInteger exponent, BigInteger m)
- Returns a BigInteger whose value is (thisexponent mod m).
import java.math.BigInteger;
import java.security.SecureRandom;
public class Main {
public static void main(String[] args) throws Exception {
int bitLength = 512; // 512 bits
SecureRandom rnd = new SecureRandom();
int certainty = 90; // 1 - 1/2(90) certainty
System.out.println("BitLength : " + bitLength);
BigInteger mod = new BigInteger(bitLength, certainty, rnd);
BigInteger exponent = BigInteger.probablePrime(bitLength, rnd);
BigInteger n = BigInteger.probablePrime(bitLength, rnd);
BigInteger result = n.modPow(exponent, mod);
System.out.println("Number ^ Exponent MOD Modulus = Result");
System.out.println("Number");
System.out.println(n);
System.out.println("Exponent");
System.out.println(exponent);
System.out.println("Modulus");
System.out.println(mod);
System.out.println("Result");
System.out.println(result);
}
}
Home
Java Book
Essential Classes
Java Book
Essential Classes
BigInteger:
- BigInteger class
- BigInteger.TEN
- BigInteger.ZERO
- Constructor
- BigInteger: add(BigInteger val)
- BigInteger: andNot(BigInteger val)
- BigInteger: bitLength()
- BigInteger: clearBit(int n)
- BigInteger: divide(BigInteger val)
- BigInteger: doubleValue()
- BigInteger: flipBit(int n)
- BigInteger: isProbablePrime(int certainty)
- BigInteger: modPow(BigInteger exponent, BigInteger m)
- BigInteger: multiply(BigInteger val)
- BigInteger: negate()
- BigInteger: not()
- BigInteger: or(BigInteger val)
- BigInteger: probablePrime(int bitLength, Random rnd)
- BigInteger: pow(int exponent)
- BigInteger: setBit(int n)
- BigInteger: shiftLeft(int n)
- BigInteger: shiftRight(int n)
- BigInteger: subtract(BigInteger val)
- BigInteger: testBit(int n)
- BigInteger: toByteArray()
- BigInteger: toString()
- BigInteger: toString(int radix)
- BigInteger: valueOf(long val)
- BigInteger: xor(BigInteger val)