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

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

 



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
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

_______________________________________________
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