111
k94314517
2025-07-14 df5ab4f34d11a7e68af1124b3d1c3bc1d79e1fd6
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
38
39
40
41
42
package com.doumee.core.utils;
 
import com.alibaba.fastjson.JSON;
import com.doumee.core.model.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;
 
import javax.servlet.http.HttpServletRequest;
 
/**
 * 安全处理工具类
 * @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());
    }
}