code: function hextoip(s) {
    var malformedMsg = "malformed hex value";
    if (! s.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))
      throw malformedMsg;
    if (s.length == 8) { // ipv4
      var ip;
      try {
        ip = parseInt(s.substr(0, 2), 16) + "." +
             parseInt(s.substr(2, 2), 16) + "." +
             parseInt(s.substr(4, 2), 16) + "." +
             parseInt(s.substr(6, 2), 16);
        return ip;
      } catch (ex) {
        throw malformedMsg;
      }
    } else if (s.length == 32) {
      return hextoipv6(s);
    } else {
      return s;
    }
  }
docs: ==== hex / ip ================================= 
  convert a hexadecimal string to IP addresss<br/>
  @name hextoip
  @function
  @param {String} s hexadecimal string of IP address
  @return {String} IP address string
  @since jsrsasign 8.0.10 base64x 1.1.13
  @description
  This function converts a hexadecimal string of IPv4 or
  IPv6 address to IPv4 or IPv6 address string.
  If byte length is not 4 nor 16, this returns a
  hexadecimal string without conversion.
  @see {@link hextoipv6}
  @example
  hextoip("c0a80101") &rarr "192.168.1.1"
  hextoip("871020010db8000000000000000000000004") &rarr "2001:db8::4"
  hextoip("c0a801010203") &rarr "c0a801010203" // 6 bytes
  hextoip("zzz")) &rarr raise exception because of not hexadecimal