How to encrypt a string using python Openssl public key?
How to encrypt a string using python Openssl public key? Question: My current code to generate an OpenSSL public-private key pair: import OpenSSL key = OpenSSL.crypto.PKey() key.generate_key(OpenSSL.crypto.TYPE_RSA, 2048) public_key = OpenSSL.crypto.dump_publickey(OpenSSL.crypto.FILETYPE_PEM, key) private_key = OpenSSL.crypto.dump_privatekey(OpenSSL.crypto.FILETYPE_PEM, key) print(public_key, private_key, sep="n") Asked By: Flow || Source Answers: The documentation recommends that you call key.to_cryptography_key() to get a …