MD5转化通用类
import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import org.slf4j.Logger;import org.slf4j.LoggerFactory;/** * MD5 转化类 * * @author Fu Wei * */public class MD5Utils {private static final Logger LOG = LoggerFactory.getLogger(MD5Utils.class);public static byte[] getMd5Key(byte[] buffer, byte[] key) {try {MessageDigest md5 = MessageDigest.getInstance("MD5");md5.update(buffer);return md5.digest(key);} catch (NoSuchAlgorithmException e) {}return null;}/** * 输入原文 返回MD5码 * * @param strSrc * @param key * @param encode * @return */public static String getMd5Key(String strSrc, String key, String encode) {try {MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(strSrc.getBytes(encode));String result = "";byte[] temp; temp = md5.digest(key.getBytes(encode));for (int i = 0; i < temp.length; i++) {result += Integer.toHexString((0x000000ff & temp[i]) | 0xffffff00).substring(6);}return result;} catch (NoSuchAlgorithmException e) {LOG.error("MD5计算出错", e);} catch (Exception e) {LOG.error("MD5装换出错", e);}return null;}}?