Java生成MD5加密字符串

来源:互联网 发布:淘宝外卖怎么看在骑手 编辑:程序博客网 时间:2024/05/16 06:59
import java.security.MessageDigest;public class MD5Utils {    public static String getMD5String(String s){        StringBuffer result = new StringBuffer();        try {            MessageDigest md5 = MessageDigest.getInstance("MD5");            md5.update(s.getBytes());            for (byte tmp: md5.digest()                 ) {                result.append(String.format("%02X", tmp));            }        }catch (Exception e){        }        return result.toString();    }}

原创粉丝点击