-
-
Save andersonbosa/16ece55e7f496b2b569b263807afb3e5 to your computer and use it in GitHub Desktop.
Revisions
-
Holger-Will revised this gist
Jul 9, 2017 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,4 @@ # generate private key openssl genrsa -out private.pem 2048 # extatract public key from it openssl rsa -in private.pem -pubout > public.pem -
Holger-Will revised this gist
Jul 9, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ const jwt2 = require('jsonwebtoken'); const fs = require("fs") const public_key = fs.readFileSync('public.pem'); const private_key = fs.readFileSync('private.pem'); var token=jwt2.sign({"user":"me"},private_key, { algorithm: 'RS256'}) -
Holger-Will created this gist
Jul 9, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ # generate private key openssl genrsa -out private.pem 2048 # extatract public key from it openssl rsa -in private.pem -pubout > public.pem # use private.pem in jwt.sign # and public.pem in jwt.verify This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ const jwt2 = require('jsonwebtoken'); const fs = require("fs") const public_key = fs.readFileSync('public.pub'); const private_key = fs.readFileSync('private.pem'); var token=jwt2.sign({"user":"me"},private_key, { algorithm: 'RS256'}) var res = jwt2.verify(token, public_key, { algorithm: 'RS256'}) console.log(res)