Voglio crittografare alcuni dati in python con PyCrypto.Come utilizzare un certificato X509 con PyCrypto?
Tuttavia ho un errore quando si utilizza key = RSA.importKey(pubkey)
:
RSA key format is not supported
La chiave è stata generata con:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mycert.key -out mycert.pem
Il codice è:
def encrypt(data):
pubkey = open('mycert.pem').read()
key = RSA.importKey(pubkey)
cipher = PKCS1_OAEP.new(key)
return cipher.encrypt(data)
prima risposta in una ricerca su Google: http://stackoverflow.com/questions/10569189/how-to-read-a-rsa-public-key-in-pem-pkcs1-format-in-python – tMC
@ tMC non funziona con me, io uso certificat e, non un file di chiave pubblica. – eshizhan