<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def hash_folder(folder, regex='[!_]*'):
 """ Get the md5 sum of each file in the folder and return to the user :param folder: the folder to compute the sums over :param regex: an expression to limit the files we match :return: Note: by default we will hash every file in the folder Note: we will not match anything that starts with an underscore """

    file_hashes = {}
    for path in glob.glob(os.path.join(folder, regex)):
        # exclude folders
        if not os.path.isfile(path):
            continue

        with open(path, 'r') as fileP:
            md5_hash = hashlib.md5(fileP.read()).digest()

        file_name = os.path.basename(path)
        file_hashes[file_name] = urlsafe_b64encode(md5_hash)
    return file_hashes