com.adtsw.jcommons.utils.HashingUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdatalayer Show documentation
Show all versions of jdatalayer Show documentation
Connectors for common java projects
The newest version!
package com.adtsw.jcommons.utils;
import java.nio.charset.StandardCharsets;
public class HashingUtil {
public static String getMd5Hash(String input) {
try {
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
byte[] array = md.digest(input.getBytes(StandardCharsets.UTF_8));
StringBuilder sb = new StringBuilder();
for (byte b : array) {
sb.append(Integer.toHexString((b & 0xFF) | 0x100).substring(1, 3));
}
return sb.toString();
} catch (java.security.NoSuchAlgorithmException e) {
throw new RuntimeException("MD5 Algorithm not found");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy