All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adtsw.jcommons.utils.HashingUtil Maven / Gradle / Ivy

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