Near Final PEP 247 - API for Cryptographic Hash Functions

Andrew Kuchling akuchlin at mems-exchange.org
Fri Sep 28 16:11:25 EDT 2001


On Fri, Sep 28, 2001 at 11:14:36AM -0400, aahz at panix.com wrote:
>Why is <module>.digest_size set to 0 if it is variable?  It should be
>None or -1, with a strong preference for None.

Backward compatibility with amkCrypto.  None makes more sense, though;
I'll change it.

>I would like to see the argument for returning digest_size in bytes when
>it is actually a bit string.  (Yes, I know the chance of having a

We program in a byte-oriented world. :) The bit size is rarely a
useful number, while if you're extracting a digest from a string (
s[pos:pos+md5.digest_size]) or a file (file.read(md5.digest_size)) you
care about the byte numbers.  A quick grep through amkCrypto Pisces
doesn't turn up any code that needs the number of bits, but there are
lots of uses of the number of bytes.

>What exactly does update() do?  Does it replace or append?

"Append", meaning that the string is hashed into the current state of
the object.

--amk





More information about the Python-list mailing list