请稍侯

jwt.io 使用方式

13 December 2022
更多

jwt在线解码

要判断认证一个token是否有效,因为使用的是RS256加密算法,所以需要手动填写公钥和私钥。 使用Java代码获取公钥和私钥,代码如下:

String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsInNjb3BlIjpbInJlYWQiLCJ3cml0ZSIsImFsbCJdLCJyb2xlcyI6WyJST0xFX01BTkFHRVIiXSwiaWQiOiIyY2IyMzZjYi03YzZlLTRmYTMtYTIwNS01OTMxYWU1M2U3NWIiLCJleHAiOjE2MTAwNjc1NjEsImF1dGhvcml0aWVzIjpbIlJPTEVfTUFOQUdFUiJdLCJqdGkiOiJjODcxYzYzMC1iOWYzLTQ1ZjItYjAzNC00ZDE1MWJmMDJhYTQiLCJjbGllbnRfaWQiOiJ3ZWJhcHAiLCJ1c2VybmFtZSI6ImFkbWluIn0.dOv9XztCUhxohb2zGC62U8Pr0Qd_5e5cUOqegsvTJon4OGBydSJNi0ptePRYaOTLVZzZcF-r89ppkCqw0aK4kzG10aJn5yhD7LgVlHMcIeGpaXMCb96xbm9qAzlYFCAtDieaLYh89y3EvyP8ZMUzgHN0XUQNJJTqLOFnsJ1OgzbDarNNHsGHTVkEKEFfY77MSiql6J-JgbhEFyb-6fjp1NCv01fXw3nSG2XNg_aIzFMZAcYG60ONoBX1wklJYykC6JoVAV4lRjdTiW-neA4QD0ZMJ_6WvqWTC57HvAPujz_F-VrXAReEXrUngcN2C6PGf3NlM-hF3p8sRJMGX6HVyv";
KeyPair keyPair = new KeyStoreKeyFactory(keyProperties.getKeyStore().getLocation(), keyProperties.getKeyStore().getSecret().toCharArray())
				.getKeyPair(keyProperties.getKeyStore().getAlias());
String pukey = Base64.encodeBase64String(keyPair.getPublic().getEncoded());
String prakey=Base64.encodeBase64String(keyPair.getPrivate().getEncoded());

生成的公钥如下:

MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkPMeU06g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Q7MdcWBJpwjaFlMQKBgQDSKEbyF0JI8kYKIYfD+nlfwuxw0MPpIb+C32e45+Qtt15/FxU3WxW+smtb/HORjmm0g1whJC3U/ICPvfQZkD1gF32OSceOtPMFMq8aSUaTau7YdEtohfMcbHJGczXkKOFMyT9jLyPeaHV71EsHgDMHDuGSIhvrH18Q/KMkyCHHkwKBgQCwkXq2Gapn/vkRgcpusq4v/yxJ0fhokLMJFLaQy5QXNJY6aHQLZK18gLA/UOCF2FfOGKGyGpKBal5QXtoj28pAzYZpxhGi2kdIe8qTzcAzeteatZykZxaUZ/nejY/+f8DzknGC8tJwxeiGNzuR0wYe+f2nxfQBUSakML+FapsIBQKBgQCA5/G0dy3SXsE1X6HORSoD4iVzgapZqri0xuHxWlPs8sgEvpzl6nnpEbmmn7AnvSn7boOpVG7EcOlOwh4jPAVZlq8OAxVj5HwYWSFsxzuCGxpMLPFAOMGJUr+5lNueirC/j8XQyc5/kqVVgj9PZ4RlNOyJ3WAwlXqTidNsMVH+/wKBgHMtw02MuoNyaQkJkILbnhMDMuHIzXFwismusFUN58GndSQOxTw1ZZIk5FO5L21ALi7sFHZ5LP6s428sIMJpeqsBJuBS62g/WWaoEgKOogUy6fgq5k68TJdsqCuMTtUmgzigW9mfCrWz9DWxS/OZI5ILY3MRB1XgmQNcJWMjopP9AoGBAImN9ke9LO4PZd1HE4J+T1aI1hpE/pYEyWp8dIjwSUKVQcAri2wujX5Rs3ZvfLqEhS02xvk0ftyTsQVaESV8fp0Qa1zp90iLbINr8ryuYGGaC7/i0/3qT68Jr3RalTOJ+XsH5v+5TxrxNvpD2a8p4j9AdIiABbhGcLY1ghiBo5sy

然后在https://jwt.io/上选择RS256,左侧写入完成token,右侧在相应位置写入公钥和私钥。

参考

参考链接:https://blog.csdn.net/wuniangzhanyan/article/details/112471667