sha, PyCrypto, SHA-256

Tim Henderson tim.tadh at gmail.com
Mon Dec 18 22:10:19 EST 2006


On Dec 16, 2:17 pm, mirandacasc... at yahoo.com wrote:
> Operating system: Win XP
> Vsn of Python: 2.4
>
> Situation is this: Required to calcluate a message digest.  The process
> for calcluating the digest must use an SHA-256 algorithm.
>
> Questions:
> 1) Is it correct that the sha module comes with python 2.4?
> 2) Is it correct that the sha module that ships with python 2.4 does
> NOT have the SHA-256 capability as part of the module?
> 3) It looks like PyCrypto is a package that, among other things,
> permits one to calculate a message digest using an SHA-256
> algorithm...is that correct?
> 4) It looks like there are a couple couple possibilities available for
> the download...either download the source code and run the setup which
> (I'm assuming) compiles the various extension modules, or download the
> pycrypto-2.0.1.win32-py2.4.zip which extracts out to a .exe; when one
> runs the just-extracted .exe, it installs the stuff on one's
> workstation.  I'm leaning toward the second option because it seems
> like most of the work has been done for me.  A quick search on this
> site didn't turn up anything that suggested there were problems with
> running the installer.  So, my question is this: are you aware of any
> problems running the installer?
> 5) Besides PyCrypto, are there any other Python packages that permit
> one to calculate a message digest using an SHA-256 algorithm?
>
> Thank you.


I have run that exact installer many many times and it works fine. to
use SHA-256 with pycrypto:

>>> from Crypto.Hash import SHA256
>>> sha = SHA256.new()
>>> sha.update('message')
>>> sha.hexdigest() # sha.digest gives the raw form
'ab530a13e45914982b79f9b7e3fba994cfd1f3fb22f71cea1afbf02b460c6d1d'

cheers
tim




More information about the Python-list mailing list