Plaintext = crypt(b64decode(encrpted_data_base64), 'Error while decrypting')įile 'c:\Users\Desktop\license.py', line 17, in įile 'C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\Cryptodome\Cipher\PKCS1_v1_5.py', line 180, in decryptįile 'C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\Cryptodome\PublicKey\RSA. As RSA is asymmetric encryption technique, if text is encrypted using public key then for decryption we should use the private key and vice versa.
We define the public key as parameter externkey which is the RSA key to import. I am making a license check where I will be encrypting the string text with private key and decrypting it with the public key, I know that it is not the standard way of decryption but I am trying to build in reverse manner for my project, the standard cryptodome library checks for private key while decryption and it returns an error and saying 'not a private key', so any idea to fix it up? public_key = b64decode(pubkey) Looks like pycrypto has not been under active development since 2014 and support ended at python 3.3.cryptography seems like the standard now. from Crypto.PublicKey import RSA from Crypto.Util import asn1 from base64 import b64decode keyDER b64decode (pubkey) seq asn1.DerSequence () seq.decode (keyDER) keyPub RSA.construct ( (seq 0, seq 1)) print keyPub.encrypt ('mysecret', 32) Thanks. When we generate a public-private keypair in PGP, it gives us the option of selecting DSA or RSA, This tool generate RSA keys. The RSA.importkey () method will import the public key to be used to encrypt, from the certificate on disk.