wzy
2020-12-26 2cf928a22b6cf8ea7a29f29127ffc333c73b0bca
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
package com.matrix.system.common.tools;
 
import com.matrix.core.tools.EncrypUtil;
import com.matrix.system.common.bean.SysUsers;
import org.apache.commons.lang.time.DateFormatUtils;
 
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
 
/**
 * 密码工具类
 * @author JIANGYOUYAO
 * @email 935090232@qq.com
 * @date Dec 11, 2017
 */
public class PasswordUtil {
 
    /**
     * 密码加密 用户密码+注册时间
     * @author JIANGYOUYAO
     * @email 935090232@qq.com
     * @date 2017年12月6日
     * @param sysUsers
     * @return
     * @throws UnsupportedEncodingException
     * @throws NoSuchAlgorithmException
     */
    public static String getEncrypUserPwd(SysUsers sysUsers) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        if (sysUsers.getSuRegisterTime() == null) {
            sysUsers.setSuRegisterTime(new Date());
        }
        String pwdSource = sysUsers.getSuPassword()
                + DateFormatUtils.ISO_DATETIME_FORMAT.format(sysUsers.getSuRegisterTime());
        return EncrypUtil.getSha1(pwdSource);
    }
 
}