jsonwebtoken generate key code example
Example 1: jsonwebtoken
$ npm install jsonwebtoken
Example 2: jsonwebtoken generate key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
Example 3: jsonwebtoken
var jwt = require('jsonwebtoken');var token = jwt.sign({ foo: 'bar' }, 'shhhhh');
Example 4: jsonwebtoken
RSASHA256(
base64UrlEncode(header) + "." +
base64UrlEncode(payload),
,
)
Example 5: jsonwebtoken
jwt.sign({ exp: Math.floor(Date.now() / 1000) + (60 * 60), data: 'foobar'}, 'secret');