comparison bin/cek.py @ 102:7a287a518718

Merge.
author Edho Prima Arief <edho@myconan.net>
date Thu, 18 Aug 2011 15:20:54 +0700
parents 08d5f6023998
children 137b18a1898e
comparison
equal deleted inserted replaced
89:29bd7f6ef58a 102:7a287a518718
1 #!/usr/bin/env python
2
3 import zlib, os, sys
4
5 def get_file_crc32(filename):
6 block_size = 1*2**20
7 return_code = 0
8 file_crc32 = 0
9 file_digest = 0
10 file_handle = open(filename, "rb")
11 if return_code == 0:
12 file_block = file_handle.read(block_size)
13 while file_block:
14 file_digest = zlib.crc32(file_block, file_digest)
15 file_block = file_handle.read(block_size)
16 file_handle.close()
17 file_digest = file_digest & 0xffffffff
18 return "%08X" % file_digest
19
20 if __name__ == "__main__":
21 for file in sys.argv[1:]:
22 print "%s %s" % (file, get_file_crc32(file))