
org.spongycastle.util.test.TestRandomBigInteger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle
intended for the Android platform. Android unfortunately ships with a stripped-down version of
Bouncy Castle, which prevents easy upgrades - Spongy Castle overcomes this and provides a full,
up-to-date version of the Bouncy Castle cryptographic libs.
The newest version!
package org.spongycastle.util.test;
import org.spongycastle.util.BigIntegers;
/**
* A fixed secure random designed to return data for someone needing to create a single BigInteger.
*/
public class TestRandomBigInteger
extends FixedSecureRandom
{
/**
* Constructor from a base 10 represention of a BigInteger.
*
* @param encoding a base 10 represention of a BigInteger.
*/
public TestRandomBigInteger(String encoding)
{
this(encoding, 10);
}
/**
* Constructor from a base radix represention of a BigInteger.
*
* @param encoding a String BigInteger of base radix.
* @param radix the radix to use.
*/
public TestRandomBigInteger(String encoding, int radix)
{
super(new FixedSecureRandom.Source[] { new FixedSecureRandom.BigInteger(BigIntegers.asUnsignedByteArray(new java.math.BigInteger(encoding, radix))) });
}
/**
* Constructor based on a byte array.
*
* @param encoding a 2's complement representation of the BigInteger.
*/
public TestRandomBigInteger(byte[] encoding)
{
super(new FixedSecureRandom.Source[] { new FixedSecureRandom.BigInteger(encoding) });
}
/**
* Constructor which ensures encoding will produce a BigInteger from a request from the passed in bitLength.
*
* @param bitLength bit length for the BigInteger data request.
* @param encoding bytes making up the encoding.
*/
public TestRandomBigInteger(int bitLength, byte[] encoding)
{
super(new FixedSecureRandom.Source[] { new FixedSecureRandom.BigInteger(bitLength, encoding) });
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy