[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnulib-tool-py] Calculating md5sum
From: |
Jim Meyering |
Subject: |
Re: [gnulib-tool-py] Calculating md5sum |
Date: |
Fri, 29 Jun 2012 08:49:07 +0200 |
Dmitriy Selyutin wrote:
> today I've investigated the code and found that there are some places where we
> need to use md5sum. There is hashlib.md5 algorithm in Python, but it returns
> different value than Linux md5sum utility.
>
> Python:
>>>> hashlib.md5(b'FILENAME').hexdigest()
> '496475a066afb2d2e50a4133b9822497'
>
> Linux:
> $ echo FILENAME | md5sum
> f2320a63dfa06e5586a86d44fe8e12eb
>
> Is it necessary how bad names are represented? It seems that Python and md5sum
> conflicts here, so we might have so call md5sum using subprocess. I'd rather
> prefer to use Python's md5, because calling subprocess is much slower.
Hi Dmitriy,
Use printf rather than "echo".
The latter emits a trailing newline.
$ printf FILENAME | md5sum
496475a066afb2d2e50a4133b9822497 -