- import java.security.MessageDigest;
- import java.security.NoSuchAlgorithmException;
- import sun.misc.BASE64Encoder;
- public class DegistUtil {
- public static String md5(String str){
- try {
- MessageDigest md = MessageDigest.getInstance("MD5");
- byte[] dist = md.digest(str.getBytes());
- BASE64Encoder baseEncode = new BASE64Encoder();
- return baseEncode.encode(dist);
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- return "";
- }
- }
- }