Re: 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

Re: Problem with sha.new

From: Rob Williscroft <rtw@freenet.co.uk>
Date: Sat Jul 09 2005 - 14:34:51 CEST

Florian Lindner wrote in news:daodmf$4gf$00$1@news.t-online.com in
comp.lang.python:

> 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)

Here you rebind 'sha' from what it was before (presumably the module sha)
to the result of 'sha.new' presumably the new 'sha' doesn't have a 'new'
method. try renameing your result variable.

> sha = sha.new(f.read())
> sha.update(f.read())
> print sha.hexdigest()

            result = sha.new(f.read())
            result.update(f.read())
            print result.hexdigest()

also I don't think you need the second call to update as f will
have been read by this time and it will add nothing.

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

> sha = sha.new(f.read())
> AttributeError: new
>

Rob.

-- 
http://www.victim-prime.dsl.pipex.com/
Received on Thu Sep 29 16:51:00 2005