If you wanna hardcode your key into your code, your key must be like this: pubkey = "-BEGIN PUBLIC KEY-\n\ In Linux (I don't know about Windows) you can check it by this command: less exteralkey.pem XgU3tAIzzBHgvwn9vANNJPzJMaOcm9kKMVJYXLHfg37IfIk1oV+/3BxMQ26ErNcC Zh7f0E5w8GZDkngceQI8nBWFPSAeQNAh0b4Vy1SYKapPrvUJdS9LsT3V9B2k2Nm1ĤlUOtfufpWP5xjoC3MwOxgBsPJsuqpe7sZddG4YzQi3IuMAcc+C/ms9mA7OX5yxt JUDqyQ6U+zyOYhoSwQpHKju2bwn6HMC8iq/ZwNqRFiqa23O2L8WSjZq4J/U1wWZ9 IEr3OwVwocSM4JPUGVSTBDcM9tGoflx8UoN4M9EJrdCcVicZEt709L13jhUxo/hX ![]() Read key from file: file = open('external.pem','r')Īnd your external key format must be something like this: -BEGIN PUBLIC KEY. If you want to import an external key using RSA.importkey( ), you have two options: ![]() KeyPriv = RSA.importKey(prvkey) # import the private keyĭecrypt_text = crypt(cipher_text, None).decode() KeyPub = RSA.importKey(pubkey) # import the public keyĬipher_text = cipher.encrypt(msg.encode()) # now we have the cipher Prvkey = """-BEGIN RSA PRIVATE KEY-įrom Crypto.Cipher import PKCS1_v1_5 as Cipher_PKCS1_v1_5 Here's my code, encrypt end decrypt, the key was from someone's blog.(if U occured with "ValueError: RSA key format is not supported", check the key format, it should be warpped with some thing like "-BEGIN XXXX KEY-") pubkey = """-BEGIN PUBLIC KEY.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |