Python - Using Hashlib

From PeformIQ Upgrade
Revision as of 19:26, 9 April 2018 by PeterHarding (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
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()