Code example for BigInteger

Methods: bitLengthmod

0
        return val;
    } 
 
    private static BigInteger hashPaddedPair(Digest digest, BigInteger N, BigInteger n1, BigInteger n2)
    { 
        int padLength = (N.bitLength() + 7) / 8;
 
        byte[] n1_bytes = getPadded(n1, padLength);
        byte[] n2_bytes = getPadded(n2, padLength);
 
        digest.update(n1_bytes, 0, n1_bytes.length);
        digest.update(n2_bytes, 0, n2_bytes.length);
 
        byte[] output = new byte[digest.getDigestSize()];
        digest.doFinal(output, 0);
 
        return new BigInteger(1, output).mod(N);
    } 
 
    private static byte[] getPadded(BigInteger n, int length)
    { 
        byte[] bs = BigIntegers.asUnsignedByteArray(n);
Contextual code suggestions in your IDE  Get Codota for Java