Here's an update, will this work best or any other suggestions?
try:
import hashlib
m1 = hashlib.md5(path)
m2 = hashlib.sha256(path)
except:
import md5
m1 = md5.new(path)
m2 = None
f = open(path,"r")
while 1:
chunk = f.read(65536)
if not chunk:
break
m1.update(chunk)
md5checksum = m1.hexdigest()
if m2:
m2.update(chunk)
shachecksum = m2.hexdigest()
storage.append(""" <checksum type="md5">%s</checksum>\n"""
% md5checksum)
if shachecksum:
storage.append(""" <checksum
type="sha256">%s</checksum>\n""" % shachecksum)
storage.append(""" </disk>\n""")
Daniel P. Berrange wrote:
On Wed, Oct 01, 2008 at 10:37:17AM -0400, Joey Boggs wrote:
I'm done creating a sha256 hash setup should I offer more than just
sha256for now? and checksum generation is off by default
Here's a preview. Not sure how to catch the module import failure for
hashlib though
If we go for doing a compulsory md5 checksum, and optional
sha256 checksum with new enough python, then something
like....
try:
import hashlib
m1 = hashlib.md5()
m2 = hashlib.sha256()
except:
import md5
m1 = md5.new()
m2 = None
Daniel
_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools