package com.util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import sun.misc.BASE64Encoder;
/**
* MD5加密解密
* @author HouYong
*
*/
public class MD5Util {
/**
* 加密
* @param message
* @return
*/
public static String encodeString(String message)
{
byte[] by = null;
try {
//获取MD5加密算法
MessageDigest md = MessageDigest.getInstance("md5");
by = md.digest(message.getBytes());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return new BASE64Encoder().encode(by);
}
/**
* 解密
* @param message
* @return
*/
public static String decodeString(String message)
{
return encodeString(message);
}
}