如何使用在线工具手动验证JWT签名
先丢一个转换地址:https://cryptii.com/
首先:
jwt分为三个部分:header,payload,verifysignature
header
{"typ":"JWT","alg":"HS256"}
base64转换: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9
![](https://img2020.cnblogs.com/blog/1532471/202101/1532471-20210116164737673-485702304.png)
转换过程中注意header里面的字符格式,空格,换行都会影响base64转换的
payload
{"sub":"1234567890","name":"John Doe","admin":true}
base64转换:eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9
![](https://img2020.cnblogs.com/blog/1532471/202101/1532471-20210116164800916-1083827737.png)
第三步:
key : secret
HMACSHA256(encodedString, 'secret')
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9
hex转换地址:https://tool.lu/hexstr/
![](https://img2020.cnblogs.com/blog/1532471/202101/1532471-20210116164822341-1788567920.png)