Javascript 字符串如何解密 JWT 加密后的 token

var token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOiIxIiwiVXNlck5hbWUiOiJhZG1pbiIsImlhdCI6MTY1MzQ2ODAwMiwibmJmIjoxNjUzNDY4MDAyLCJleHAiOjE2NTM0NjkyMDIsImlzcyI6ImRvdG5ldGNoaW5hIiwiYXVkIjoicG93ZXJieSBGdXJpb24ifQ.kEp3TTIl9C0rNZ9vD2AwgapUw_0yGi6Mc2H8qWxHNRI";
token = token.replace("_", "/").replace("-", "+") // 添加这一行
var json = window.atob(token.split(".")[1]);
console.log(JSON.parse(json));
posted @ 2022-05-25 17:01  Rustln  阅读(836)  评论(0编辑  收藏  举报