]>
gitweb.pimeys.fr Git - scripts-20-100.git/blob - md5sum.py
2 # -*- encoding: utf-8 -*-
4 ## trouvé sur http://code.activestate.com/recipes/266486/
12 ## Simple md5 hash utility for generating md5 checksums of files.
14 ## usage: md5hash <filename> [..]
16 ## Use '-' as filename to sum standard input.
22 '''Returns an md5 hash for an object with read() method.'''
33 '''Returns an md5 hash for file fname, or stdin if fname is "-".'''
35 ret
= sumfile(sys
.stdin
)
40 return 'Failed to open file'
46 # if invoked on command line, print md5 hashes of specified files.
47 if __name__
== '__main__':
48 for fname
in sys
.argv
[1:]:
49 print '%32s %s' % (md5sum(fname
), fname
)