package com.java1234.util;
import org.apache.shiro.codec.Base64;
import org.apache.shiro.crypto.hash.Md5Hash;
public class CryptographyUtil {
/**
* base64加密
* @param str
* @return
*/
public static String encBase64(String str){
return Base64.encodeToString(str.getBytes());
}
/**
* base64解密
* @param str
* @return
*/
public static String decBase64(String str){
return Base64.decodeToString(str);
}
/**
* Md5加密 加盐,就是加入符号
* @param str
* @param salt
* @return
*/
public static String md5(String str,String salt){
return new Md5Hash(str,salt).toString();
}
public static void main(String[] args) {
String password="123456";
System.out.println("Base64加密:"+CryptographyUtil.encBase64(password));
System.out.println("Base64解密:"+CryptographyUtil.decBase64(CryptographyUtil.encBase64(password)));
System.out.println("Md5加密:"+CryptographyUtil.md5(password, "java1234"));
}
}
-----------------------------------------------------------------------------
是否被记住
-----------------------------------------------------------------------------
是否被记住
try{
if(subject.isRemembered()){
System.out.println("被记住");
}
else{
token.setRememberMe(true);
}
}catch(Exception e){
e.printStackTrace();
}