How to export a private key / public key into bytes with Python cryptography module?
I tried many combinations of parameters of rsa.RSAPrivateKey.private_bytes but none of them work: from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, PublicFormat, NoEncryption private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048, backend=default_backend()) pvt_bytes = private_key.private_bytes(Encoding.Raw, PrivateFormat.Raw, NoEncryption()) # ERROR # ValueError: format is invalid with this key public_key = private_key.public_k
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.