Python PyCrypto and RSA problem
I'e got simple RSA python script:
import Crypto.PublicKey.RSA
import rsakey
from Crypto.PublicKey import pubkey
# Some global stuff
impl = Crypto.PublicKey.RSA.RSAImplementation(use_fast_math = True)
RSAObj = impl.construct(rsakey.RSAKeys)
def decrypt(encrypted):
return RSAObj.decrypt(encrypted)
and when I try to run it my CLI shows error:
Traceback (most recent 开发者_JAVA百科call last):
File "otrsa.py", line 6, in impl = Crypto.PublicKey.RSA.RSAImplementation(use_fast_math = True) AttributeError: 'module' object has no attribute 'RSAImplementation'
I'm really new to Python and I don't know what it means. I would be thankful for any kind of help.
Crypto.PublicKey.RSA contains a class called RSAImplementation (see http://www.dlitz.net/software/pycrypto/apidoc/Crypto.PublicKey.RSA.RSAImplementation-class.html).
The following works for me (in Python 2.7.1 on 32-bit Windows):
import Crypto.PublicKey.RSA
impl = Crypto.PublicKey.RSA.RSAImplementation()
Note that, by default, fast math will be used if it is available. Forcing use_fast_math just causes a runtime error if it is not available.
Hmmm, I get the same error -- perhaps some miss-match between the docs and code?
What little I've used pyCrypto, I've found M2Crypto to be a better library overall -- you might want to try it out.
It means that Crypto.PublicKey.RSA does not have the function/variable called 'RSAImplementation"
精彩评论