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