Top Description Fields Constructors Methods
org.bouncycastle.crypto.util

public Class RadixConverter

extends Object
Class Inheritance
Imports
java.math.BigInteger, org.bouncycastle.util.BigIntegers

Utility class to convert decimal numbers (BigInteger) into a number in the base provided and the other way round.

For an application of this see the FPE parameter classes.

Field Summary

Modifier and TypeField and Description
private static final int
private final int
private final BigInteger[]
private final BigInteger
private static final double
private final int

Constructor Summary

AccessConstructor and Description
public
RadixConverter(int
the radix to use for base conversions
radix
,
int
number of intermediate base powers to precompute and cache.
numberOfCachedPowers
)

public
RadixConverter(int
the radix to use for base conversions.
radix
)

Method Summary

Modifier and TypeMethod and Description
public BigInteger
fromEncoding(short[] digits)

private long
fromEncoding(int groupStartDigitIndex, int groupEndDigitIndex, short[] digits)

public int
public int
private BigInteger[]
precomputeDigitsGroupPowers(int numberOfCachedPowers, BigInteger digitsGroupSpaceSize)

public void
toEncoding(BigInteger number, int messageLength, short[] out)

private int
toEncoding(long number, int digitIndex, short[] out)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_POWERS_TO_CACHEback to summary
private static final int DEFAULT_POWERS_TO_CACHE
digitsGroupLengthback to summary
private final int digitsGroupLength
digitsGroupSpacePowersback to summary
private final BigInteger[] digitsGroupSpacePowers
digitsGroupSpaceSizeback to summary
private final BigInteger digitsGroupSpaceSize
LOG_LONG_MAX_VALUEback to summary
private static final double LOG_LONG_MAX_VALUE
radixback to summary
private final int radix

Constructor Detail

RadixConverterback to summary
public RadixConverter(int radix, int numberOfCachedPowers)
Parameters
radix:int

the radix to use for base conversions

numberOfCachedPowers:int

number of intermediate base powers to precompute and cache.

RadixConverterback to summary
public RadixConverter(int radix)
Parameters
radix:int

the radix to use for base conversions.

Method Detail

fromEncodingback to summary
public BigInteger fromEncoding(short[] digits)
fromEncodingback to summary
private long fromEncoding(int groupStartDigitIndex, int groupEndDigitIndex, short[] digits)
getDigitsGroupLengthback to summary
public int getDigitsGroupLength()
getRadixback to summary
public int getRadix()
precomputeDigitsGroupPowersback to summary
private BigInteger[] precomputeDigitsGroupPowers(int numberOfCachedPowers, BigInteger digitsGroupSpaceSize)
toEncodingback to summary
public void toEncoding(BigInteger number, int messageLength, short[] out)
toEncodingback to summary
private int toEncoding(long number, int digitIndex, short[] out)