importshaimportosdefcreatesha(directory):"""Walk through a Directory creating Sha Hashes of each file path"""forroot,dirs,filesinos.walk(str(directory)):fornameinfiles:filepath=os.path.join(root,name)value=sha.new(filepath).hexdigest()printvalue
This example is misleading. The comment in the function states that it takes checksums of each file, but the function itself only takes checksums of the file paths found in a directory not their contents.
Here is a small modification that will also make the output compatible with 'sha1sum -c' :-
This example is misleading. The comment in the function states that it takes checksums of each file, but the function itself only takes checksums of the file paths found in a directory not their contents.
Here is a small modification that will also make the output compatible with 'sha1sum -c' :-
I made a more robust version of the previous commenters code if anyone reading this is interested:
http://akiscode.com/articles/sha-1directoryhash.shtml