How to load a public RSA key into Python-RSA from a file?

前端 未结 5 1089
南笙
南笙 2020-12-31 10:08

I generated a private and a public key using OpenSSL with the following commands:

openssl genrsa -out private_key.pem 512
openssl rsa -in private_key.pem -pu         


        
5条回答
  •  暖寄归人
    2020-12-31 10:27

    If on Python3, You also need to open the key in binary mode, e.g:

    with open('private_key.pem', 'rb') as privatefile:
    

提交回复
热议问题