def generate_rsa_key_pair(key_size=2048):
 private_key = rsa.generate_private_key(public_exponent=65537, key_size=key_size, backend=default_backend())
 private_key_str = private_key.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption())
 public_key_str = private_key.public_key().public_bytes(Encoding.PEM, PublicFormat.SubjectPublicKeyInfo)
 print public_key_str
 print private_key_str

def generate_rsa_key_pair ( key_size = 2048 ) : private_key = rsa . generate_private_key ( public_exponent = 65537 , key_size = key_size , backend = default_backend ( ) ) private_key_str = private_key . private_bytes ( Encoding . PEM , PrivateFormat . PKCS8 , NoEncryption ( ) ) public_key_str = private_key . public_key ( ) . public_bytes ( Encoding . PEM , PublicFormat . SubjectPublicKeyInfo ) print public_key_str print private_key_str
generates a public and private rsa pem encoded key pair .