[英]pycrypto and python 2.4.3 issue
I am working on a project and the cPanel which is provided to me by employer is having python 2.4.3
(too old version). 我正在开发一个项目,雇主提供给我的cPanel具有
python 2.4.3
(版本太旧)。 The problem is i need to use pycrypto
. 问题是我需要使用
pycrypto
。 So i am importing SHA256
. 所以我要导入
SHA256
。 The problem is here SHA256.py: 问题在这里SHA256.py:
try:
import hashlib
hashFactory = hashlib.sha256
except ImportError:
from Crypto.Hash import _SHA256
hashFactory = _SHA256
hashlib
is not available in python 2.4.3 so it went to import _SHA256
but there is no _SHA256 in Cryto.Hash
folder. hashlib
在python 2.4.3中不可用,因此它导入了_SHA256
但Cryto.Hash
文件夹中没有_SHA256。 Is this is bug of pycrypto? 这是pycrypto的错误吗? or i can not use this module for python 2.4.3??
还是我不能为python 2.4.3使用此模块? Any workaround for this problem?
任何解决此问题的方法?
Quite a few algorithms in PyCrypto are actually written in C, rather than in pure python. PyCrypto中相当多的算法实际上是用C编写的,而不是纯Python编写的。 SHA256 is amongst them.
SHA256就在其中。 In order to use it, you must either install a complete pycrypto binary package or follow the instructions in the PyCrypto's README file.
为了使用它,您必须安装完整的pycrypto二进制软件包或按照PyCrypto的README文件中的说明进行操作。 In the latter case, you will need to install the development environment first.
在后一种情况下,您将需要首先安装开发环境。
Both options are platform and OS specific, but once done, it will be simply a matter of calling: 这两个选项都是特定于平台和操作系统的,但是一旦完成,只需调用即可:
from Crypto.Hash import SHA256
hash = SHA256.new()
hash.update('message')
There is no need to try to import it from hashlib
first. 无需先尝试从
hashlib
导入它。
您可以尝试使用独立的hashlib库 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.