Java BigInteger to bigIntToHash(BigInteger keyValue)

Here you can find the source of bigIntToHash(BigInteger keyValue)

Description

big Int To Hash

License

Apache License

Declaration

private static String bigIntToHash(BigInteger keyValue) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigInteger;

public class Main {
    private static String bigIntToHash(BigInteger keyValue) throws Exception {
        String hashKey = keyValue.toString(16);
        if (hashKey.length() > 32) {
            throw new Exception("Invalid value.");
        }// w w  w. ja va 2 s .  c o m
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 32 - hashKey.length(); ++i) {
            sb.append("0");
        }
        sb.append(hashKey);
        return sb.toString().toUpperCase();
    }
}

Related

  1. bigIntegerToHex(final BigInteger bigInteger)
  2. bigIntegerToList(BigInteger number)
  3. bigIntegerToString(final BigInteger value)
  4. bigIntegerToUnsignedByteArray(BigInteger a, int len)
  5. bigIntToArray(BigInteger data)
  6. bigIntToHex(BigInteger big)
  7. bigIntToIpV6(BigInteger argInt)
  8. BigIntToPaddedByteArray(BigInteger bi, int length)
  9. bigIntToSortableBytes(BigInteger bigInt, int bigIntSize, byte[] result, int offset)