21 lines
524 B
Java
21 lines
524 B
Java
import java.math.BigInteger;
|
|
|
|
public class bytetohex {
|
|
public static String toHexString(byte[] hash)
|
|
{
|
|
// Convert byte array into signum representation
|
|
BigInteger number = new BigInteger(1, hash);
|
|
|
|
// Convert message digest into hex value
|
|
StringBuilder hexString = new StringBuilder(number.toString(16));
|
|
|
|
// Pad with leading zeros
|
|
while (hexString.length() < 64)
|
|
{
|
|
hexString.insert(0, '0');
|
|
}
|
|
|
|
return hexString.toString();
|
|
}
|
|
}
|