package com.sinata.jwt; import com.alibaba.fastjson.JSON; import com.sinata.rest.core.util.MD5Util; import com.sinata.rest.modular.auth.converter.BaseTransferEntity; import com.sinata.rest.modular.auth.security.impl.Base64SecurityAction; import java.util.HashMap; import java.util.Map; /** * jwt测试 */ public class DecryptTest { public static void main(String[] args) { // 认证信息,随机字符串 String salt = "w742mp"; // 认证信息,token String token = "Bearer eyJhbGciOiJIUzUxMiJ9.eyJyYW5kb21LZXkiOiJ3NzQybXAiLCJzdWIiOiIxIiwiZXhwIjoxNTkxMjY3NzYzLCJpYXQiOjE1OTA2NjI5NjN9.q2TRbsTf_YnNLaCnmDvM_pNNvHHB3RN69GFzZy5vMcyS2Zl3lyMH1Fsw7sFshtUBn3QQE0m8yqbxa0Qlq_jXAA"; // 模拟请求参数 Map map = new HashMap<>(); map.put("id", "11"); map.put("current", "22"); map.put("size", "33"); // 1、请求参数实体转Json字符串 String jsonString = JSON.toJSONString(map); // 2、对Json字符串(请求参数)进行Base64加密 String encode = new Base64SecurityAction().doAction(jsonString); // 3、Base64加密后的Json字符串(请求参数) + 随机字符串,进行Md5加密 String md5 = MD5Util.encrypt(encode + salt); BaseTransferEntity baseTransferEntity = new BaseTransferEntity(); // Json字符串(请求参数)进行Base64加密,实体字符串 baseTransferEntity.setObject(encode); // Base64加密后的Json字符串(请求参数) + 随机字符串,进行Md5加密,签名字符串 baseTransferEntity.setSign(md5); System.out.println(JSON.toJSONString(baseTransferEntity)); } }