RS256

node v10.24.1
version: master
endpointsharetweet
const jwt = require('jsonwebtoken') const privateKey=`-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgHskuZKKc7NL447r40FHHyX3lv8Cf5KybCauK8SRUswnuI3F+e0C bwtMfjkg0j7wQDH2HCCjEsiwTjXJd9QxWcxb38gdLrpHRftdWaeWYs41aoWJGiBk DBHjKLqLGzmYhQaGl37XzNUqab/32DdsI1Fme7o9ANEwUPxsEWQvsMMbAgMBAAEC gYApGWO6Le1ZrP1g6Qeq9MLHmC/UIpBTdKs16bF/5IS+0I7++lFksgg/vCLwjCy/ hs3WHu7aUbLmOjmQKBKPRn1ShdtEKuM5K1pCd7Anj4YLsQjGTRJONNgKw5U9nQiw YYbvghERLOVPhfab3IPfhYZW7Ye4KmjBjKjU/5zkxHdn+QJBAOYpfSj2hW187atD I34Fq7ee8DTCElHpkkemgKsPPelG5mYicbSZXePkrp/RPr8DTAVVgm7iBsZP9YLp h9R0UIUCQQCI966ubKmsLo1T3TLupNeY1mrPl0a9UEDy8tzEaQlFMI9rXgnfXv/n ZoLG4NPu2CFUemJt6jeVXNMsmFHBF+cfAkBmWwMPKXqy80DazfPFwo3YDfWy8K+m /+GOvaww5olY6a/iseSxNRc9FuDVr/9ggP3YzWtBFoF+xeZf/qzqPYPlAkEAiBeC K7GwjXLb3j5lgxWrWyOBka7ADQ8W2c9SaJ3tJiBwAMC5koa0Qtpqiu2N5z49L9FC x+/3NqO6+A6I/RGhBQJBAK1oJCuv9sl1EWRoLOpr3THcIV3xL3jHyckt7EpNBaTT Upkj9+K/+wNwjNXvlPvYRjuLn5M83NGsuBCWL+h+ZL8= -----END RSA PRIVATE KEY-----` const token = jwt.sign({ user: 'York' }, privateKey, { algorithm: 'RS256' });
const cert = `-----BEGIN PUBLIC KEY----- MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgHskuZKKc7NL447r40FHHyX3lv8C f5KybCauK8SRUswnuI3F+e0CbwtMfjkg0j7wQDH2HCCjEsiwTjXJd9QxWcxb38gd LrpHRftdWaeWYs41aoWJGiBkDBHjKLqLGzmYhQaGl37XzNUqab/32DdsI1Fme7o9 ANEwUPxsEWQvsMMbAgMBAAE= -----END PUBLIC KEY-----` const decoded = jwt.verify(token, cert) console.log(decoded.user)
Loading…

no comments

    sign in to comment