I am getting the error :
data = cipher.encrypt(data)
File "/usr/lib/python2.7/dist-packages/Crypto/Cipher/PKCS1_OAEP.py", line 133, in encrypt
randFunc = self._key._randfunc
AttributeError: 'str' object has no attribute '_randfunc'
in my console for the following section of code:
cipher = PKCS1_OAEP.new(PK_ID)
data = cipher.encrypt(data)
both the PK_ID and data are both of Str
what does the error message mean and how can i solve it for this code?
1 Answer 1
The PKCS1_OAEP.new() function takes an RSA key object, which you can get from the Crypto.PublicKey.RSA module, it doesn't take a str.
answered Jul 16, 2014 at 23:53
Alex Gaynor
15.1k10 gold badges66 silver badges113 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
user3842234
So i would need to pass an 'instance' to the PKCS1_OAEP.new() function ?, is there anyway to convert the PK_ID to this for it to be acepted ?
lang-py