Pu Zhibing
2025-05-09 8580866e175ad0050ee9c5ea3f757856fc242c39
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.stylefeng.guns.modular.system.util;
 
import lombok.SneakyThrows;
 
import java.security.MessageDigest;
 
public class MD5Util {
    @SneakyThrows
    public static String encrypt32(String encryptStr) {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        byte[] md5Bytes = md5.digest(encryptStr.getBytes());
        StringBuilder hexValue = new StringBuilder();
        for (int i = 0; i < md5Bytes.length; i++) {
            int val = ((int) md5Bytes[i]) & 0xff;
            if (val < 16) {
                hexValue.append("0");
            }
            hexValue.append(Integer.toHexString(val));
        }
        return hexValue.toString().toUpperCase();
    }
}