import io


def hex_to_bin(s):
    """Converts a string of hex digits to bytes"""
    stream = io.StringIO(s)
    data = b""
    while True:
        char_hex = stream.read(2)
        if not char_hex:
            break
        char_int = int(char_hex, 16)
        data += char_int.to_bytes(1, byteorder="big")
    return data