![]() Public_key = RSA.import_key(open("mykey.pub").read())Ĭipher_priv = PKCS1_OAEP. Private_key = RSA.import_key(open("mykey.pem").read()) RSA is public-key cryptography involving two keys, public key which is available for all the users on the internet and private key, only with the authorized person. # It's important to also use our swapped logic in encryption step, otherwise the lib would still use e&n (the private contains all 3 values). Return int(pow(Integer(ciphertext), self._e, self._n))ĭata = "I met aliens in UFO. Return int(pow(Integer(plaintext), self._d, self._n)) So, you could extend the RSA-Key class with that swapped logic, use blackmagic to swap the implementation of the loaded key, and pass it to the normal functions: from import RsaKey This being said, I want to emphasize that I'm not a crypto expert and cannot say for certain that this doesn't compromise security. ![]() ![]() It is as you say indeed possible to encrypt with private and decrypt with public, the mathematical symmetry in RSA allows just swapping e/d in the keys and then calling the encrypt/decrypt functions. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |