md5加密工具类

package cn.itcast.estore01.utils;

import java.math.BigInteger; import java.security.MessageDigest;

import java.security.NoSuchAlgorithmException;

public class MD5Utils {

  byte[] secretBytes = null;
   try {

      secretBytes = MessageDigest.getInstance("md5").digest(plainText.getBytes());

    } catch (NoSuchAlgorithmException e) {

    throw new RuntimeException("加密失败");
    }

  return new BigInteger(1, secretBytes).toString(16);

}

public static void main(String[] args) {
  System.out.println(md5("root"));// 63a9f0ea7bb98050796b649e85481845
  // 63a9f0ea7bb98050796b649e85481845
 }
}

原文地址:https://www.cnblogs.com/jasonlee880709/p/5978853.html