org.bouncycastle.crypto.test.BigIntegersTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk15on Show documentation
Show all versions of bcprov-jdk15on Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 and up.
package org.bouncycastle.crypto.test;
import java.math.BigInteger;
import org.bouncycastle.util.BigIntegers;
import org.bouncycastle.util.test.SimpleTest;
import org.bouncycastle.util.test.TestRandomData;
public class BigIntegersTest
extends SimpleTest
{
public String getName()
{
return "BigIntegers";
}
public void performTest()
throws Exception
{
BigInteger min = BigInteger.valueOf(5);
isTrue(min.equals(BigIntegers.createRandomPrime(min.bitLength(), 1,
new TestRandomData(BigIntegers.asUnsignedByteArray(min)))));
BigInteger max = BigInteger.valueOf(743);
isTrue(max.equals(BigIntegers.createRandomPrime(max.bitLength(), 1,
new TestRandomData(BigIntegers.asUnsignedByteArray(max)))));
}
public static void main(String[] args)
throws Exception
{
runTest(new BigIntegersTest());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy