I want calculate crc of file, and get output like [E45A12AC] I don't want md5 or other.
#!/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)
calculates for each line crc, but its output <-1767935985> per line is not what i want. How to get output like: [E45A12AC] ?
is it posible with zlib.crc32 do something like:
import hashlib
m = hashlib.md5()
for line in open('data.txt', 'rb'):
m.update(line)
print m.hexdigest()