import hashlib


def hash_str(s, hash_type='md5'):
    """Hash the string using the default md5 hash function.  If the string is
    actually a None, then just return None.

    :param s: string to hash
    :hash_type: default 'md5', but any hash function from the hashlib
    :returns: the hashed string
    """
    if s is None:
        return None
    h = getattr(hashlib, hash_type)()
    h.update(str(s))
    return h.hexdigest()