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

com.arch.util.Md5Utils Maven / Gradle / Ivy

There is a newer version: 18.12.0
Show newest version
package com.arch.util;

import org.apache.commons.codec.binary.Hex;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Md5Utils {
	public static String generate(String value) {
    	try {
    		MessageDigest md = MessageDigest.getInstance("MD5");
    		return Hex.encodeHexString(md.digest(value.getBytes()));
        } catch (NoSuchAlgorithmException ex) {
        	LogUtils.generate(ex);
        }
    	return "";
    }
	
	@Deprecated
    public static String generate2(String value) {
        String sen = "";
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        BigInteger hash = new BigInteger(1, md.digest(value.getBytes()));
        sen = hash.toString(16);
        return sen;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy