Near Final PEP 247 - API for Cryptographic Hash Functions

Boyd Roberts boyd at
Sat Sep 29 01:20:27 CEST 2001

"Andrew Kuchling" <akuchlin at> a écrit dans le message news: mailman.1001707952.19388.python-list at
> We program in a byte-oriented world. :)

MD5 is _bit_ orientated.

> >What exactly does update() do?  Does it replace or append?
> "Append", meaning that the string is hashed into the current state of
> the object.

it has to appended to the current MD5 block.  when you have
a whole block you can process the block.  could you clarify
what you just said?

the digest is computed on the padded block and it's length:

    /* pad message */
    *me++ = 0x80;

    if ((me - mb) > MSG_LEN0_BYTE)
        /* digest this block and substitute a padded block */
        bzero(me, MSG_BYTES - (me - mb));
        md5block(mb, digest);
        bzero(mb, MSG_LEN0_BYTE);
        bzero(me, MSG_LEN0_BYTE - (me - mb));

    /* append size in bits */
    unpack(bits[0], &mb[MSG_LEN0_BYTE]);
    unpack(bits[1], &mb[MSG_LEN1_BYTE]);
    md5block(mb, digest);

if you want all the code:

More information about the Python-list mailing list