compute crc of file in python
I want to calculate the CRC of file and get output like: E45A12AC . Here's my code: #!/usr/bin/env python import os, sys import zlib def crc(fileName): fd = open(fileName,"rb") content = fd.readlines() fd.close() for eachLine in content: zlib.crc32(eachLine) for eachFile in sys.argv[1:]: crc(eachFile) This calculates the CRC for each line, but its output (e.g. -1767935985 ) is not what I want. Hashlib works the way I want, but it computes the md5: import hashlib m = hashlib.md5() for line in open('data.txt', 'rb'): m.update(line) print m.hexdigest() Is it possible to get something similar