Problem with sha.new
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

Problem with sha.new

From: Florian Lindner <Florian.Lindner@xgm.de>
Date: Sat Jul 09 2005 - 13:49:12 CEST

Hello,
I try to compute SHA hashes for different files:

for root, dirs, files in os.walk(sys.argv[1]):
    for file in files:
        path = os.path.join(root, file)
        print path
        f = open(path)
        sha = sha.new(f.read())
        sha.update(f.read())
        print sha.hexdigest()

this generates a traceback when sha.new() is called for the second time:

/home/florian/testdir/testfile
c95ad0ce54f903e1568facb2b120ca9210f6778f
/home/florian/testdir/testfile2
Traceback (most recent call last):
  File "duplicatefinder.py", line 11, in ?
    sha = sha.new(f.read())
AttributeError: new

What is wrong there?

Thanks,

Florian
Received on Thu Sep 29 16:50:56 2005