By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,994 Members | 1,166 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,994 IT Pros & Developers. It's quick & easy.

doing "checksum" in python

P: n/a
is there a built-in function that does a "checksum" on a file...basicly
counts the bytes and computes a 16-bit checksum for each given FILE.

this is the like the "sum" command in unix

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
GujuBoy wrote:
is there a built-in function that does a "checksum" on a file...basicly
counts the bytes and computes a 16-bit checksum for each given FILE.

this is the like the "sum" command in unix

Try zlib.adler32 or zlib.crc32 ...?
import zlib
zlib.crc32(open("c:\\boot.ini").read())

-1176164168

--Irmen
Jul 18 '05 #2

P: n/a
On 28 Mar 2005 15:11:32 -0800, GujuBoy <di*****@gmail.com> wrote:
is there a built-in function that does a "checksum" on a file...basicly
counts the bytes and computes a 16-bit checksum for each given FILE.

this is the like the "sum" command in unix

--
http://mail.python.org/mailman/listinfo/python-list


Not built-in, but you can find a few implementations with a quick
google search for "python 16-bit checksum":
http://mail.python.org/pipermail/pyt...ay/042691.html
http://mail.python.org/pipermail/pyt...ry/204983.html
http://mail.python.org/pipermail/pyt...ry/204998.html

--
Sean Blakey
Saint of Mild Amusement, Evil Genius, Big Geek
Python/Java/C++/C(Unix/Windows/Palm/Web) developer
quine = ['print "quine =",quine,"; exec(quine[0])"'] ; exec(quine[0])
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.