MCPcopy Create free account
hub / github.com/LisenCoding/cangku / MD5Utils

Class MD5Utils

boot/src/main/java/com/utils/MD5Utils.java:7–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5import java.security.NoSuchAlgorithmException;
6
7public 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected