2021与蓝度共同重构项目,服务端
chenjiantian
2021-11-24 6bdb5dda11b8723ddc20a37b9cbcc1e1fdace13a
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
39
40
41
42
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解析异常");
        }
 
    }
 
}