public class Md5Utils {
????????????/**
????????????* 利用MD5進行加密
????????????* @param str 待加密的字符串
????????????* @return 加密后的字符串
????????????* @throws NoSuchAlgorithmException
????????????* @throws UnsupportedEncodingException
????????????*/
????????????public static String EncoderByMd5(String str) {
????????????????????if (str == null) {
????????????????????????????return null;
????????????????????}
????????????????????try {
????????????????????????????// 確定計算方法
? ? ? ? ? ? ? ? ? ? ? ? ? ? MessageDigest md5 = MessageDigest.getInstance("MD5");
????????????????????????????BASE64Encoder base64en = new BASE64Encoder();
????????????????????????????// 加密后的字符串
????????????????????????????return base64en.encode(md5.digest(str.getBytes("utf-8")));
????????????????????} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
????????????????????????????return null;
????????????????????}
????????}
}