Files
Phoenix/bin/mymd5.py
Per A. Brodtkorb e4e8bf8317 Fixes issue 1571:
Adding missing close for open.
If the "close()" call is missing after a "open(filename)" call, the filename isn't guaranteed to be closed before the interpreter exits.
This is generally a bad practice as explained here: https://stackoverflow.com/questions/7395542/is-explicitly-closing-files-important

Also replaced "fid=open(filename) fid.close()" statements for files with the safer
"with open(filename) as fid:" blocks. See https://www.python.org/dev/peps/pep-0343/
2020-03-23 17:16:44 +01:00

16 lines
319 B
Python

import sys
import glob
import hashlib
def main():
for arg in sys.argv[1:]:
for name in glob.glob(arg):
m = hashlib.md5()
with open(name, 'rb') as fid:
m.update(fid.read())
print('%-45s %s' % (name, m.hexdigest()))
if __name__ == '__main__':
main()