pluto/scripts/make-jwt.py

21 lines
528 B
Python
Raw Normal View History

2021-12-23 00:29:33 +00:00
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.backends import default_backend
from json import load
import jwt
PRIVATE_KEY = "pkcs8privatekey.pem"
PAYLOAD = "jwt"
with open(PRIVATE_KEY, "rb") as f:
pem_bytes = f.read()
with open(PAYLOAD, "rb") as f:
payload = load(f)
print(pem_bytes)
print(payload)
private_key = serialization.load_pem_private_key(pem_bytes, password=None, backend=default_backend())
encoded = jwt.encode(payload, private_key, algorithm="RS256")
print(encoded)