import socket


def str_to_inet(ip: str) -> bytes:
    """
    Converts a string representation of IP address to binary representation.
    :param ip: IP like - "123.45.67.89"
    :return: 32 bit representation of "123.45.67.89" like - '{-CY'
    """
    try:
        return socket.inet_pton(socket.AF_INET, ip)
    except OSError:
        return socket.inet_pton(socket.AF_INET6, ip)