Java Utililty Methods BigInteger to

List of utility methods to do BigInteger to

Description

The list of methods to do BigInteger to are organized into topic(s).

Method

byte[]bigIntegerToBytes(final BigInteger bigInteger)
Wandelt einen BigInteger in ein vorzeichenloses Byte-Array um.
byte[] bytes = bigInteger.toByteArray();
if (bytes[0] == 0) {
    return Arrays.copyOfRange(bytes, 1, bytes.length);
return bytes;
int[]bigIntegerToDigits(BigInteger n)
big Integer To Digits
String s = n.toString();
int size = s.length();
int[] retval = new int[size];
for (int i = 0; i < size; i++) {
    retval[i] = Integer.parseInt(String.valueOf(s.charAt(i)));
return retval;
byte[]BigIntegerToEightBytes(BigInteger value)
This function converts big integer to eight bytes.
byte[] result = new byte[8];
byte[] tmp = value.toByteArray();
if (tmp.length > 8) {
    System.arraycopy(tmp, tmp.length - 8, result, 0, 8);
} else {
    System.arraycopy(tmp, 0, result, 8 - tmp.length, tmp.length);
return result;
...
StringbigIntegerToHex(final BigInteger bigInteger)
Wandelt einen BigInteger in vorzeichenlose Hex-Darstellung um.
return bytesToHex(bigIntegerToBytes(bigInteger));
ListbigIntegerToList(BigInteger number)
Transforms a BigInteger number to a List of Integer .
if (number == null) {
    return new ArrayList<>(0);
String bitArray = number.toString(2);
List<Integer> result = new ArrayList<>();
int length = bitArray.length();
for (int index = length - 1; index >= 0; --index) {
    if (bitArray.charAt(index) == '1') {
...
StringbigIntegerToString(final BigInteger value)
Customized string representation of BigInteger.
if (value == null) {
    return "null";
} else if (value.signum() < 0) {
    return "-0x" + value.negate().toString(16);
} else {
    return "0x" + value.toString(16);
byte[]bigIntegerToUnsignedByteArray(BigInteger a, int len)
big Integer To Unsigned Byte Array
byte[] buf = new byte[len];
if (a.bitLength() > len * 8)
    throw new NumberFormatException("BigInteger doesn't fit into array");
byte[] b = a.toByteArray();
if (b.length == len + 1)
    if (b[0] == 0)
        for (int i = 0; i < buf.length; i++)
            buf[i] = b[i + 1];
...
int[]bigIntToArray(BigInteger data)
big Int To Array
List<Integer> dataList = new ArrayList<Integer>();
for (int i = 0; data.bitCount() > 0; i++, data = data.shiftRight(1)) {
    if (data.testBit(0))
        dataList.add(i);
int[] dataArr = new int[dataList.size()];
for (int i = 0; i < dataArr.length; i++)
    dataArr[i] = dataList.get(i);
...
StringbigIntToHash(BigInteger keyValue)
big Int To Hash
String hashKey = keyValue.toString(16);
if (hashKey.length() > 32) {
    throw new Exception("Invalid value.");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 32 - hashKey.length(); ++i) {
    sb.append("0");
sb.append(hashKey);
return sb.toString().toUpperCase();
StringbigIntToHex(BigInteger big)
big Int To Hex
return big.toString(16);