code: function iptohex(s) {
    var malformedMsg = "malformed IP address";
    s = s.toLowerCase(s);
  
    if (s.match(/^[0-9.]+$/)) {
      var a = s.split(".");
      if (a.length !== 4) throw malformedMsg;
      var hex = "";
      try {
        for (var i = 0; i < 4; i++) {
          var d = parseInt(a[i]);
          hex += ("0" + d.toString(16)).slice(-2);
        }
        return hex;
      } catch(ex) {
        throw malformedMsg;
      }
    } else if (s.match(/^[0-9a-f:]+$/) && s.indexOf(":") !== -1) {
      return ipv6tohex(s);
    } else {
      throw malformedMsg;
    }
  }
docs: convert IPv4/v6 addresss to a hexadecimal string<br/>
  @name iptohex
  @function
  @param {String} s IPv4/v6 address string
  @return {String} hexadecimal string of IP address
  @since jsrsasign 8.0.12 base64x 1.1.14
  @description
  This function converts IPv4 or IPv6 address string to
  a hexadecimal string of IPv4 or IPv6 address.
  @example
  iptohex("192.168.1.1") &rarr "c0a80101"
  iptohex("2001:db8::4") &rarr "871020010db8000000000000000000000004"
  iptohex("zzz")) &rarr raise exception