package com.sandu.common.util;
|
|
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.json.JSONUtil;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.json.JsonMapper;
|
import com.sandu.common.execption.BusinessException;
|
import com.sandu.common.object.TokenData;
|
|
/**
|
* @author chenjiantian
|
* @date 2021/8/14 15:02
|
*/
|
public class AesUtil {
|
|
private final static byte[] sKey = {56, -30, 1, 49, -8, -119, -120, 1, 89, -102, 57, 12, 117, 68, -38, 39};
|
|
/**
|
* 加密
|
* @param text
|
* @return
|
*/
|
public static String encrypt(String text) {
|
String token = SecureUtil.aes(sKey).encryptHex(text);
|
return token;
|
}
|
|
public static void main(String[] args) {
|
System.out.println(encrypt("2"));
|
}
|
public static String decrypt(String text) {
|
try {
|
String s = SecureUtil.aes(sKey).decryptStr(text);
|
return s;
|
}catch (Exception e){
|
throw new BusinessException("token解析异常");
|
}
|
|
}
|
|
}
|