Skip to main content
Used a more direct cross reference (as user names can change at any time).
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

I don't like loops. Based on @Nathan FegerNathan Feger's answer:

md5 = hashlib.md5() with open(filename, 'rb') as f: functools.reduce(lambda _, c: md5.update(c), iter(lambda: f.read(md5.block_size * 128), b''), None) md5.hexdigest() 

I don't like loops. Based on @Nathan Feger:

md5 = hashlib.md5() with open(filename, 'rb') as f: functools.reduce(lambda _, c: md5.update(c), iter(lambda: f.read(md5.block_size * 128), b''), None) md5.hexdigest() 

I don't like loops. Based on Nathan Feger's answer:

md5 = hashlib.md5() with open(filename, 'rb') as f: functools.reduce(lambda _, c: md5.update(c), iter(lambda: f.read(md5.block_size * 128), b''), None) md5.hexdigest() 
Source Link
Sebastian Wagner
  • 2.6k
  • 2
  • 30
  • 35

I don't like loops. Based on @Nathan Feger:

md5 = hashlib.md5() with open(filename, 'rb') as f: functools.reduce(lambda _, c: md5.update(c), iter(lambda: f.read(md5.block_size * 128), b''), None) md5.hexdigest()