Re: [patch] virt-convert add disk signature into virt-image format export

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux