mirror of
https://github.com/201206030/novel-plus.git
synced 2025-07-06 17:26:40 +00:00
上传后台管理系统代码
This commit is contained in:
@ -0,0 +1,28 @@
|
||||
package com.java2nb.common.utils;
|
||||
|
||||
import org.apache.shiro.crypto.hash.SimpleHash;
|
||||
import org.apache.shiro.util.ByteSource;
|
||||
|
||||
public class MD5Utils {
|
||||
private static final String SALT = "1qazxsw2";
|
||||
|
||||
private static final String ALGORITH_NAME = "md5";
|
||||
|
||||
private static final int HASH_ITERATIONS = 2;
|
||||
|
||||
public static String encrypt(String pswd) {
|
||||
String newPassword = new SimpleHash(ALGORITH_NAME, pswd, ByteSource.Util.bytes(SALT), HASH_ITERATIONS).toHex();
|
||||
return newPassword;
|
||||
}
|
||||
|
||||
public static String encrypt(String username, String pswd) {
|
||||
String newPassword = new SimpleHash(ALGORITH_NAME, pswd, ByteSource.Util.bytes(username + SALT),
|
||||
HASH_ITERATIONS).toHex();
|
||||
return newPassword;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
//System.out.println(MD5Utils.encrypt("admin", "1"));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user