【发布时间】:2015-02-11 21:16:04
【问题描述】:
我使用 odoo,我想安装 paybox 模块:这个:https://bitbucket.org/anybox/anybox_paybox/ 为此:这个模块需要 pycrypto 才能工作
所以,我在linux服务器(ubuntu)中安装了pycrypto
git clone https://github.com/dlitz/pycrypto.git./configurepython setup.py buildpython setup.py install
我做了这个测试:python setup.py test 结果没有错误,但问题来了:在这个文件中 //paybox_signature.py//
# coding: utf-8
import urllib
import base64
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
from Crypto.Hash import SHA
class Signature():
def verify(self, signature, msg, key):
""" check if the signature is correct according to the public key path given
and the message """
msg = self.remove_sign(msg)
key = RSA.importKey(key)
ha = SHA.SHA1Hash().new(msg)
verifier = PKCS1_v1_5.new(key)
signature = urllib.unquote(signature)
signature = base64.b64decode(signature)
return verifier.verify(ha, signature)
def remove_sign(self, msg):
""" remove signature arg from the given string"""
pos = msg.find('&Signature')
if pos == -1:
return msg
return msg[:pos]
当我执行文件的这一行时:
from Crypto.PublicKey import RSA
--> 没问题就ok
当我这样做时
from Crypto.Signature import PKCS1_v1_5
--> Traceback(最近一次调用最后一次): 文件“”,第 1 行,在 ImportError: 没有名为 Signature 的模块
我不知道为什么 所有模块都在那里,为什么python会出现这个错误!我真的不知道 我需要你的帮助谢谢你
【问题讨论】: