Python - Using Hashlib

From PeformIQ Upgrade
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()