package com.sgl.util; import java.security.MessageDigest; import sun.misc.BASE64Encoder; /** * 密码加密工具类 * @author xiaosu * */ public class MD5Util { /** * 对密码进行MD5加密 * @param password * @return */ public static String encoderPasswordByMD5(String password) throws Exception{ MessageDigest md5 = MessageDigest.getInstance("MD5");//获取md5实例 BASE64Encoder base64Encoder = new BASE64Encoder();//编码规则的实例 return base64Encoder.encode(md5.digest(password.getBytes("utf-8"))); } }