[PYTHON-CRYPTO] Hashing modules

Michael Ströder michael at STROEDER.COM
Sat Feb 10 19:15:16 CET 2001


Andrew Kuchling wrote:
>
> Let's take a look at the interface for hashing.  Here are the docs
> from amkCrypto:
> [..]

This seems reasonable to me.

> >>> from Crypto.Hash import MD5
> >>> m = MD5.new()
> >>> m.update('abc')
> >>> m.digest()
> '\220\001P\230<\322O\260\326\226?@}(\341\177r'

Slightly different:

>>> import Crypto
>>> md5 = Crypto.getInstance('MD5')
>>> md5.update('abc')
>>> md5.digest()
> '\220\001P\230<\322O\260\326\226?@}(\341\177r'

> Does this seem a reasonable interface for a hash algorithm?

Yes.

> Anything missing?  Anything that can be dropped?
> (.hexdigest() probably isn't needed... or is it?)

Yes, drop .hexdigest() but add method .reset() that a dynamically
created object can be re-used.

Also we should try to implement a Codec-like StreamWriter() /
StreamReader() class for that like mentioned by M.-A. Lemburg on the
(deprecated) eGroups list.

Ciao, Michael.





More information about the python-crypto mailing list