wired md5 hashing problem
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

wired md5 hashing problem

From: Matthias Güntert <MatzeGuentert@gmx.de>
Date: Sun Mar 26 2006 - 16:56:27 CEST

Hello list-members

i am in the process of writing a python script to backup my data. Now I
would like to implement md5/sha1 hashes. =20

    # do md5 fingerprinting=20
    if config.get("global", "crc") =3D=3D "md5":
        m =3D md5.new()
        # open the file=20
        f =3D open(fname, "rb")
        while 1:
            block =3D f.read(1024*1024)
            if not block:
                break
            # generate the hash
            m.update(block)
        f.close()
             =20
        # write the results properly formated to a file
        fd =3D file(fname + ".md5", "w")
        fd.write(m.hexdigest())
        fd.write(" " + fname + "\n")
        fd.close()

mguentert@uranos > md5sum -c backup.tar.bz2.md5 =20
/fileservice/temp/backup.tar.bz2: FAILED
md5sum: WARNING: 1 of 1 computed checksum did NOT match

mguentert@uranos > cat backup.tar.bz2.md5 =20
d41d8cd98f00b204e9800998ecf8427e /fileservice/temp/backup.tar.bz2

so the format should be okay, but whats wrong with my piece of code?!

Greetings

--=20
Mit freundlichen Gr=FC=DFen

                Matthias G=FCntert

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (GNU/Linux)

iD8DBQBEJquauQEWmvzea70RArn0AKC+ktZwzHUcXY+qqgN+Yj50p5ilzACdE7X5
+apebd9xy1GCHeRGhHbw3Hc=
=ZDGF
-----END PGP SIGNATURE-----

[plaintext signature.asc.1143384987.873766302]
Received on Sun Apr 30 21:13:35 2006