MD5 File Hash Example
#!/usr/bin/python3
# ===================================================================
# MD5 hash of a file
# ===================================================================

import hashlib
import user_interface as ui

# -------------------------------------------------------------------
# MD5 file hash example found on the web
# -------------------------------------------------------------------

def file_md5_hash(filename):
    with open(filename,'rb') as f:
        file_hash = hashlib.md5()
        chunk = f.read(8192)
        while chunk:
            file_hash.update(chunk)
            chunk = f.read(8192)
    return file_hash

# -------------------------------------------------------------------
# main
# -------------------------------------------------------------------

if __name__ == '__main__':

    while(True):

        print()
        s = ui.get_user_input('Enter file name: ')
        if not s:
            print()
            break

        h = file_md5_hash(s)
   
        print()
        print(f'MD5 file hash is {h.hexdigest()}')