def wrap_hashlib(hasher, length=None):
    """
    Wraps hashlib's functions, returning a function that returns the hex-digest of its input.

    >>> from hashlib import sha1
    >>> wrap_hashlib(sha1)(b'heyo')
    'f8bb1031d6d82b30817a872b8a2ec31d5380cee5'

    :param hasher: A function from :mod:`hashlib`
    :return: Function
    """

    args = []
    if length is not None:
        args = [length]

    def _hasher(data):
        return hasher(data).hexdigest(*args)

    return _hasher