from hashlib import md5 as md5_func
import json


def md5(d, enc='utf-8'):
    """
    Returns MD5 hash of the dictionary (dumped to the string) in hex format
    :param d: dictionary
    :param enc: strung encoding
    :return: MD5 digest string
    """
    return md5_func(json.dumps(d).encode(enc)).hexdigest()