Created
December 30, 2023 17:45
-
-
Save unacceptable/4d4bf2d61cf6390f92774f7c07a3144c to your computer and use it in GitHub Desktop.
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 characters
# macos | |
ssh-keygen -t rsa -b 4096 -E SHA512 -m PEM -f ~/my.jwt.RS512.pem | |
# pip install pyjwt | |
python <<PYTHON | |
import os | |
import logging | |
import jwt | |
logging.basicConfig(level=logging.INFO) | |
HOME = os.environ['HOME'] | |
with open(f'{HOME}/my.jwt.RS512.pem.pub', 'r') as pub_key_file: | |
pub_key = pub_key_file.read() | |
with open(f'{HOME}/my.jwt.RS512.pem', 'r') as private_key_file: | |
private_key = private_key_file.read() | |
payload = { | |
"nothing": "secret" | |
} | |
encoded = jwt.encode(payload, private_key, algorithm="RS512") | |
logging.info(encoded) | |
decoded = jwt.decode(encoded, pub_key, algorithms=["RS512"]) | |
logging.info(decoded) | |
PYTHON |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment