Question

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). The problem is i need to use pycrypto. So i am importing SHA256. The problem is here 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. Is this is bug of pycrypto? or i can not use this module for python 2.4.3?? Any workaround for this problem?

Was it helpful?

Solution

You could try using the standalone hashlib library.

OTHER TIPS

Quite a few algorithms in PyCrypto are actually written in C, rather than in pure python. SHA256 is amongst them. In order to use it, you must either install a complete pycrypto binary package or follow the instructions in the PyCrypto's README file. 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top