注:JWT_SECERT为加的盐
public static Claims parseJWT(String jwt) throws Exception {
SecretKey secretKey = generalKey();
return Jwts.parser()
.setSigningKey(secretKey)
.parseClaimsJws(jwt)
.getBody();
}
public static SecretKey generalKey() {
byte[] encodedKey = Base64.decode(JWT_SECERT);
SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, “AES”);
return key;
}
jwt根据token获取用户信息
最新推荐文章于 2023-09-18 16:53:07 发布