1
zj
10 days ago 8f2dffccbf56283bbb3f281f7dc3aeeab982cafb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.nq.vo.pay;
 
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
 
/**
 * @program: dabaogp
 * @description:
 * @create: 2026-03-02 15:18
 **/
public class PayOutMD5Util {
 
    public static String md5(String source) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] bytes = md.digest(source.getBytes("UTF-8"));
            return bytesToHex(bytes);
        } catch (NoSuchAlgorithmException | java.io.UnsupportedEncodingException e) {
            throw new RuntimeException("MD5加密失败", e);
        }
    }
 
    private static String bytesToHex(byte[] bytes) {
        StringBuilder sb = new StringBuilder();
        for (byte b : bytes) {
            sb.append(String.format("%02x", b));
        }
        return sb.toString();
    }
 
}