md5 from python different then md5 from command line

Just just at xs4all.nl
Sun May 7 12:24:50 CEST 2006


In article <1146996448.577162.283480 at j73g2000cwa.googlegroups.com>,
 "ursache.marius at gmail.com" <ursache.marius at gmail.com> wrote:

> I noticed that the md5 computed with md5 module from python is
> different then the md5 sum computed with md5sum utility (on slackware
> and gentoo).
> 
> i.e.
> $echo marius|md5sum
> 0f0f60ac801a9eec2163083a22307deb -
> 
> >>> test = md5.new("marius")
> >>> print test.hexdigest()
> 242aa1a97769109065e3b4df359bcfc9
> 
> 
> Any idea why? and how to get the same md5 sum for both calls?

echo adds a newline:

   >>> import md5
   >>> test = md5.new("marius\n")
   >>> print test.hexdigest()
   0f0f60ac801a9eec2163083a22307deb

Just



More information about the Python-list mailing list