[io] sha512

This commit is contained in:
Johannes Frohnmeyer 2022-09-18 15:48:08 +02:00
parent 50442e31e3
commit a68578f73f
Signed by: Johannes
GPG Key ID: E76429612C2929F4
1 changed files with 11 additions and 0 deletions

View File

@ -27,6 +27,17 @@ public class HashUtils {
return formatter.toString();
}
public static String sha512(byte[] data) {
Formatter formatter = new Formatter();
try {
for (byte b : MessageDigest.getInstance("SHA-512").digest(data))
formatter.format("%02x", b);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Could not hash using SHA512", e);
}
return formatter.toString();
}
public static long murmur2(byte[] data) {
final int m = 0x5bd1e995;
final int r = 24;