我有一个简单的RSA python脚本:
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)当我尝试运行它时,我的CLI会显示错误:
跟踪(最近一次调用):
文件"otrsa.py",第6行,在impl =otrsa.py= True) AttributeError中:‘模块’对象没有属性'RSAImplementation‘
我对Python非常陌生,我不知道这意味着什么。我会感谢任何帮助。
发布于 2010-12-28 02:23:13
Crypto.PublicKey.RSA包含一个名为RSAImplementation的类(参见http://www.dlitz.net/software/pycrypto/apidoc/Crypto.PublicKey.RSA.RSAImplementation-class.html)。
以下内容适用于我(在32位Windows上使用Python2.7.1):
import Crypto.PublicKey.RSA
impl = Crypto.PublicKey.RSA.RSAImplementation()注意,默认情况下,如果可用,将使用快速数学。如果use_fast_math不可用,强迫它只会导致运行时错误。
发布于 2010-12-28 00:42:53
嗯,我也有同样的错误--也许是文档和代码之间的不匹配?
我很少使用pyCrypto,我发现M2Crypto总体上是一个更好的库--您可能需要尝试一下。
发布于 2010-12-28 00:46:18
这意味着Crypto.PublicKey.RSA没有称为‘RSAImplementation’的函数/变量。
https://stackoverflow.com/questions/4542477
复制相似问题