Difference between revisions of "Python - Using Hashlib"

From PeformIQ Wiki
Jump to navigation Jump to search
(Created page with " <pre> import hashlib def get_sha256_hash(filename): m = hashlib.sha256() with open(filename, 'rb', buffering=0) as f: for b in iter(lambda : f.read(128*1024), b''):...")
(No difference)

Revision as of 19:26, 9 April 2018

import hashlib

def get_sha256_hash(filename):
  m = hashlib.sha256()

  with open(filename, 'rb', buffering=0) as f:
    for b in iter(lambda : f.read(128*1024), b''):
      m.update(b)

  return m.hexdigest()