I need to generate a pair of private and public keys in Python. I used to generate them on the site mkjwk, but I want to automate this process.
I need to generate keys in a format like the ones highlighted in yellow in the picture.
I tried to use the cryptography
library to solve this problem.
I managed to generate a private key in the required format, but I don’t know how to generate a public key.
key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048,
)
private_key = key.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.TraditionalOpenSSL,
encryption_algorithm=serialization.NoEncryption(),
)
I would be very grateful for any help with this. This does not have to be done with the cryptography
library, if there is a better way.