0

This should be simple (famous last words)

In the terminal, i can run this command:

winpty openssl genrsa -des3 -out my_rsa_key_pair 2048

How can I do the exact same thing using pyca/cryptography ?

President James K. Polk
  • 40,516
  • 21
  • 95
  • 125
Dallas Caley
  • 5,367
  • 6
  • 40
  • 69

1 Answers1

2

The Fernet method is not used as a method for generating RSA keys. Therefore, Fernet-based RSA key generation is not supported by pyca/cryptography. However, you can generate RSA keys in the pyca/cryptography package like this:

from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.backends import default_backend

private_key = rsa.generate_private_key(
    public_exponent=65537, # Commonly used public exponent
    key_size=2048, # Key size in bits
    backend=default_backend()
)

public_key = private_key.public_key()

Hope this helps.

President James K. Polk
  • 40,516
  • 21
  • 95
  • 125
g.newt
  • 105
  • 3