How to use .pem file with Python M2Crypto
问题 To generate an RSA key pair I used openssl: openssl genrsa -out my_key.private.pem 1024 openssl rsa -in my_key.private.pem -pubout -out my_key.public.pem Now I want to use this my_key.public.pem file in a function of another .py file: import M2Crypto from M2Crypto import RSA,SSL def encrypt(): pk = open( 'my_key.public.pem', 'rb' ).read() rsa = M2Crypto.RSA.load_pub_key(pk) print rsa; Am I doing it right? Both files are in same directory, but this function is not giving any output. 回答1: