Skip to content

Instantly share code, notes, and snippets.

@productdevbook
Last active May 18, 2022 03:14
Show Gist options
  • Save productdevbook/955a7e69e4dc3f88fdf0862fd7aea243 to your computer and use it in GitHub Desktop.
Save productdevbook/955a7e69e4dc3f88fdf0862fd7aea243 to your computer and use it in GitHub Desktop.
JWT Generate

Generate the RSA keys

openssl genrsa -out private.pem 2048 openssl rsa -in private.pem -pubout > public.pem

Yukaridaki kisim openssl kullarak rs256 sifreleme sistemini kullanarak bir gizli key yaratiyor. Sonra bu gizli keyden public key yaratiyoruz.

Bu iki key sistemde kullaniyoruz. Jwt sifrelenirken public key ile sifrenip karsiya gonderiyor. Karsi taraf bize istek attiginda tokeni public key ile cozuyoruz.

print the keys in an escaped format

awk -v ORS='\n' '1' private.pem awk -v ORS='\n' '1' public.pem

awk -v ORS='\\n' '1' private.pem

example js used

secretOrKey: configService
        .get<string>('JWT_PUBLIC_KEY')
        .replace(/\\n/g, '\n'),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment