def byte(value):
    """Converts a char or int to its byte representation."""
    if isinstance(value, str) and len(value) == 1:
        return ord(value)
    elif isinstance(value, int):
        if value > 127:
            return byte(value - 256)
        if value < -128:
            return byte(256 + value)
        return value