That's one thing I forgot to move out of the loop before I sent it. I was still working on the handling of m2 missing prior to that and put it inside the loop for testing. Once moved should that be good to go?

Daniel P. Berrange wrote:
On Wed, Oct 01, 2008 at 12:27:46PM -0400, Joey Boggs wrote:
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()

hexdigest() should only be called at end, outside
the loop. As it stands you're computing a checksum
for each chunk & resetting it

Daniel

_______________________________________________
et-mgmt-tools mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

Reply via email to