xiaoyong931011
2022-09-23 f9a7691e2175281dd972ae2ad2beb73bc3fd0650
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package cc.mrbird.febs.common.utils;
 
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;
 
/**
 * @author MrBird
 */
public class Md5Util {
 
    private static final String ALGORITH_NAME = "md5";
 
    private static final int HASH_ITERATIONS = 5;
 
    public static String encrypt(String username, String password) {
        String source = StringUtils.lowerCase(username);
        password = StringUtils.lowerCase(password);
        return new SimpleHash(ALGORITH_NAME, password, ByteSource.Util.bytes(source), HASH_ITERATIONS).toHex();
    }
}