md5 wrongness?

Erik Max Francis max at alcyone.com
Sat Nov 24 03:58:17 CET 2007


Ron Johnson wrote:

> $ echo "snagglefrob" | md5sum
> f842244d79af85b457811091319d85ff  -
> 
> $ python
> Python 2.4.4 (#2, Aug 16 2007, 02:03:40)
> [GCC 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import md5
>>>> s = md5.new()
>>>> s.update('snagglefrob')
>>>> s.hexdigest()
> '9eb2459fcdd9f9b8a9fef7348bcac933'

echo inserts a newline, your Python snippet doesn't.

% echo -n "snagglefrob" | md5sum
9eb2459fcdd9f9b8a9fef7348bcac933  -

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
   Granted that I must die, how shall I live?
    -- Michael Novak



More information about the Python-list mailing list