import hashlib


def hash_string(string, hash_type=hashlib.md5):
    """
    Hashes the given string with the desired type, defaults to MD5.
    """

    hash_state = hash_type()

    hash_state.update(string)

    return hash_state.hexdigest()