def sum_(hash_func, data):
    """
    // sum returns the hash of the input data using the specified algorithm.
    """
    if data is None:
        return None
    result = hash_func(data)
    if hasattr(result, 'digest'):
        result = result.digest()
    return result
