[Tutor] Different md5 values for files under Unix and Python?
Blake Winton
bwinton at latte.ca
Thu Jan 15 14:27:29 EST 2004
(Oops, I just sent this to Clay, whereas it probably should
have gone to the whole list...)
> So I'm hashing some files, and I get different outputs for
>
> os.popen("md5 filename") and hash.update("filename");
> digest=hash.digest()
>
> which outputs
>
> 543117d4fc8b2ac471a88a1baa1f2b59 book.txt
> 6a2b6248246f2ec5682688c63c477f1e book.txt
>
> Puzzled.
Well, would it help if I showed you this:
-bash-2.05b$ md5 -r -s "book.txt"
543117d4fc8b2ac471a88a1baa1f2b59 "book.txt"
-bash-2.05b$ md5 -r "book.txt"
md5: book.txt: No such file or directory
-bash-2.05b$ python
Python 2.2.2 (#1, Mar 22 2003, 15:26:17)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> import md5
>>> hash = md5.md5()
>>> hash.update( "book.txt" )
>>> hash.hexdigest()
'543117d4fc8b2ac471a88a1baa1f2b59'
Later,
Blake.
More information about the Tutor
mailing list