doum
2025-09-23 920ad7c1062549f8ff6e5034f84a90c725dc89dd
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
32
33
34
35
36
37
package com.doumee.core.utils;
 
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;
 
/**
 * 安全处理工具类
 * @author  dm
 * @since 2025/03/31 16:44
 */
@Slf4j
@Component
public class Secure {
 
    /**
     * 加密密码
     *
     * @param password 密码
     * @param salt 密码盐
     * @return String
     */
    public String encryptPassword(String password, String salt) {
        return this.encryptMD5Password(DigestUtils.md5DigestAsHex(password.getBytes()), salt);
    }
 
    /**
     * 加密密码
     *
     * @param md5Password 密码
     * @param salt 密码盐
     * @return String
     */
    public String encryptMD5Password(String  md5Password, String salt) {
        return DigestUtils.md5DigestAsHex((md5Password + salt).getBytes());
    }
}