| 5 | import java.security.NoSuchAlgorithmException; |
| 6 | |
| 7 | public class MD5Utils { |
| 8 | public static String md5(String plainText) { |
| 9 | byte[] secretBytes = null; |
| 10 | try { |
| 11 | secretBytes = MessageDigest.getInstance("md5").digest( |
| 12 | plainText.getBytes()); |
| 13 | } catch (NoSuchAlgorithmException e) { |
| 14 | throw new RuntimeException("没有这个md5算法!"); |
| 15 | } |
| 16 | String md5code = new BigInteger(1, secretBytes).toString(16); |
| 17 | for (int i = 0; i < 32 - md5code.length(); i++) { |
| 18 | md5code = "0" + md5code; |
| 19 | } |
| 20 | return md5code; |
| 21 | } |
| 22 | } |
nothing calls this directly
no outgoing calls
no test coverage detected