SHA256 hash in Python 2.4

hyperboreean picture hyperboreean · Aug 25, 2009 · Viewed 10.4k times · Source

Is there a way I can calculate a SHA256 hash in Python 2.4 ? (I emphasize: Python 2.4) I know how to do it in Python 2.5 but unfortunately it's not available on my server and an upgrade will not be made. I have the same problem as the guy in this question, but using Python 2.4. Any help will be greatly appreciated.

EDIT: Sorry, I mean SHA 256. I was too in a hurry. Sorry again.

Answer

af. picture af. · Aug 25, 2009

Yes you can. With Python 2.4, there was SHA-1 module which does exactly this. See the documentation.

However, bear in mind that code importing from this module will cause DeprecationWarnings when run with newer Python.

Ok, as the requirement was tightened to be SHA-256, using the SHA-1 module in standard library isn't enough. I'd suggest checking out pycrypto, it has a SHA-256 implementation. There are also windows binary releases to match older Pythons, follow the links from Andrew Kuchlings old PyCrypto page.