-
-
Save havenwood/90067d0e37353f0e8dc5a0dfc7868952 to your computer and use it in GitHub Desktop.
This file contains 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 characters
rsa_private = OpenSSL::PKey::RSA.generate 2048 | |
rsa_public = rsa_private.public_key | |
File.write 'jwt-key.pub', rsa_public | |
secret = {'sekret' => 'Cicadoidea'} | |
payload = JWT.encode secret, rsa_private, 'RS256' | |
pub = File.read 'jwt-key.pub' | |
rsa_public_key = OpenSSL::PKey::RSA.new pub | |
decrypted_payload, _ = JWT.decode payload, rsa_public_key, true, {algorithm: 'RS256'} | |
decrypted_payload | |
#=> {"sekret"=>"Cicadoidea"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment