java_passwords/bytetohex.java

21 lines
524 B
Java
Raw Normal View History

2023-10-23 18:01:19 +11:00
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();
}
}