Function iptohex

  • convert IPv4/v6 addresss to a hexadecimal string

    Parameters

    • sIn: string

      IPv4/v6 address string

    Returns string

    hexadecimal string of IP address

    See

    • hextoip
    • ipv6tohex

    Description

    This function converts IPv4 or IPv6 address string to a hexadecimal string of IPv4 or IPv6 address.

    Example

    iptohex("192.168.1.1") -> "c0a80101"
    iptohex("2001:db8::4") -> "871020010db8000000000000000000000004"
    iptohex("192.168.1.1/24") -> "c0a80101ffffff00"
    iptohex("2001:db8::/120") -> "871020010db8000000000000000000000000ffffffffffffffffffffffffffffffffff00"
    iptohex("zzz")) -> raise exception