import binascii


def string_to_hex(val: str, min_length: int = 0) -> str:
    """
    Create a hex representation of val. The end of the result will be padded
    with "0" until min_length is reached.

    Args:
        val: The string to convert.
        min_length: The minimum length of result. "0" will be used as
            padding. Default is no minimum length and no padding.

    Returns:
        Hex string
    """
    hex_string = binascii.hexlify(val.encode()).decode()
    hex_string_length = len(hex_string)
    if hex_string_length < min_length:
        return hex_string + "0" * (min_length - hex_string_length)
    return hex_string