Hash an array of bytes, @x, using @relicHashFunc and returns the result
    of @elementType.

def _hash(x, elementType, relicHashFunc):
    """
    Hash an array of bytes, @x, using @relicHashFunc and returns the result
    of @elementType.
    """
    # Combine all inputs into a single bytearray
    barray = bytearray()
    map(barray.extend, bytes(x))

    # Create an element of the correct type to hold the hash result
    result = elementType()

    # Convert barray into a modifiable ctypes buffer, hash using the provided
    # function, and return the result.
    buf = getBuffer(barray)
    relicHashFunc(byref(result), byref(buf), sizeof(buf))
    return result