This topic describes the syntax and parameters of encoding and decoding functions and provides function examples.

Functions

Type Function Description
URL url_encoding Encodes URL data.
url_decoding Decodes URL data.
Base64 base64_encoding Encodes data into Base64.
base64_decoding Decodes data from Base64.
HTML html_encoding HTML encodes data.
html_decoding Decodes HTML-encoded data.
MD5 md5_encoding Calculates the MD5 hash value for data.
SHA1 sha1_encoding Calculates the SHA value for data.
IP address ip2long Converts an IP address to a Long value.
long2ip Converts a Long value to an IP address.

url_encoding

  • Syntax
    url_encoding(Value)
  • Parameters
    Parameter Data type Required Description
    Value String Yes The value to be encoded
  • Response

    A URL-encoded string is returned.

  • Example
    Raw log entry:
    content : https://www.urlencoder.org/hello/asdah
    Transformation rule:
    e_set("url",url_encoding(v("content")))
    Result:
    content : https://www.urlencoder.org/hello/asdah
    url: https%3A%2F%2Fwww.urlencoder.org%2FHello%2Fasdah

url_decoding

  • Syntax
    url_decoding(Value)
  • Parameters
    Parameter Data Type Required Description
    Value String Yes The value to be decoded
  • Response

    A URL-decoded string is returned.

  • Example
    Raw log entry:
    content : https%3A%2F%2Fwww.urlencoder.org%2FHello%2Fasdah
    Transformation rule:
    e_set("URL",url_decoding(v("content")))
    Result:
    content : https%3A%2F%2Fwww.urlencoder.org%2FHello%2Fasdah
    URL : https://www.urlencoder.org/hello/asdah

base64_encoding

  • Syntax
    base64_encoding(Value)
  • Parameters
    Parameter Data Type Required Description
    Value String Yes The value to be encoded
  • Response

    A Base64-encoded string is returned.

  • Example
    Raw log entry:
    str_en : data to be encoded
    Transformation rule:
    e_set("str_base64",base64_encoding(v("str_en")))
    Result:
    str_en : data to be encoded
    str_base64 : ZGF0YSB0byBiZSBlbmNvZGVk

base64_decoding

  • Syntax
    base64_decoding(Value)
  • Parameters
    Parameter Data Type Required Description
    Value String Yes The value to be decoded
  • Response

    A Base64-decoded string is returned.

  • Example
    Raw log entry:
    str_de: ZGF0YSB0byBiZSBlbmNvZGVk
    Transformation rule:
    e_set("str_de_base64",base64_decoding(v("str_de")))
    Result:
    str_de: ZGF0YSB0byBiZSBlbmNvZGVk
    str_de_base64: data to be encoded

html_encoding

  • Syntax
    html_encoding(Value)
  • Parameters
    Parameter Data Type Required Description
    Value String Yes The value to be encoded
  • Response

    An HTML-encoded string is returned.

  • Example
    Raw log entry:
    str : <img class="size-medium wp-image-113" style="margin-left: 15px;" title="su1" src="http://blah.org/wp-content/uploads/2008/10/su1-300x194.jpg" alt="" width="300" height="194" />
    Transformation rule:
    e_set("str_html_en",html_encoding(v("str")))
    Result:
    str : <img class="size-medium wp-image-113" style="margin-left: 15px;" title="su1" src="http://blah.org/wp-content/uploads/2008/10/su1-300x194.jpg" alt="" width="300" height="194" />
    str_html_en : &lt;img class=&quot;size-medium wp-image-113&quot; style=&quot;margin-left: 15px;&quot; title=&quot;su1&quot; src=&quot;http://blah.org/wp-content/uploads/2008/10/su1-300x194.jpg&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;194&quot; /&gt;

html_decoding

  • Syntax
    html_decoding(Value)
  • Parameters
    Parameter Data Type Required Description
    Value String Yes The value to be decoded
  • Response

    An HTML-decoded string is returned.

  • Example
    Raw log entry:
    str : &lt;img class=&quot;size-medium wp-image-113&quot; style=&quot;margin-left: 15px;&quot; title=&quot;su1&quot; src=&quot;http://blah.org/wp-content/uploads/2008/10/su1-300x194.jpg&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;194&quot; /&gt;
    Transformation rule:
    e_set("str_html_de",html_decoding(v("str")))
    Result:
    str : &lt;img class=&quot;size-medium wp-image-113&quot; style=&quot;margin-left: 15px;&quot; title=&quot;su1&quot; src=&quot;http://blah.org/wp-content/uploads/2008/10/su1-300x194.jpg&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;194&quot; /&gt;
    str_html_de : <img class="size-medium wp-image-113" style="margin-left: 15px;" title="su1" src="http://blah.org/wp-content/uploads/2008/10/su1-300x194.jpg" alt="" width="300" height="194" />

md5_encoding

  • Syntax
    md5_encoding(Value)
  • Parameters
    Parameter Data Type Required Description
    Value String Yes The value to be encoded
  • Response

    An MD5 hash value is returned.

  • Example
    Raw log entry:
    str : GeeksforGeeks
    Transformation rule:
    e_set("str_md5_en",md5_encoding(v("str")))
    Result:
    str : GeeksforGeeks
    str_md5_en : f1e069787ece74531d112559945c6871

sha1_encoding

  • Syntax
    sha1_encoding(Value,format=None)
  • Parameters
    Parameter Data Type Required Description
    Value String Yes The value to be encoded.
    format String No The SHA algorithm. Default value: SHA1. Valid values: SHA1, SHA256, SHA384, SHA224, and SHA512.
  • Response

    A SHA1-encoded string is returned.

  • Example
    Raw log entry:
    str : GeeksforGeeks
    Transformation rule:
    e_set("str_sha1",sha1_encoding(v("str")))
    e_set("str_sha512",sha1_encoding(v("str"),format='SHA512'))
    e_set("str_sha224",sha1_encoding(v("str"),format='SHA224'))
    e_set("str_sha384",sha1_encoding(v("str"),format='SHA384'))
    e_set("str_sha256",sha1_encoding(v("str"),format='SHA256'))
    Result:
    str : GeeksforGeeks
    str_sha1 : 4175a37afd561152fb60c305d4fa6026b7e79856
    str_sha512 : 0d8fb9370a5bf7b892be4865cdf8b658a82209624e33ed71cae353b0df254a75db63d1baa35ad99f26f1b399c31f3c666a7fc67ecef3bdcdb7d60e8ada90b722
    str_sha224 : 173994f309f727ca939bb185086cd7b36e66141c9e52ba0bdcfd145d
    str_sha384 : d1e67b8819b009ec7929933b6fc1928dd64b5df31bcde6381b9d3f90488d253240490460c0a5a1a873da8236c12ef9b3
    str_sha256 : f6071725e7ddeb434fb6b32b8ec4a2b14dd7db0d785347b2fb48f9975126178f

ip2long

  • Syntax
    ip2long(Value,default=0)
  • Parameters
    Parameter Data Type Required Description
    Value String Yes The value to be decoded.
    default String No The value to which an invalid IP address is converted. You can customize the value of this parameter. Default value: 0.
  • Response:

    The LONG value converted from a valid IP address is returned.

  • Examples
    • Example 1: A valid IP address is passed to the function.
      Raw log entry:
      ip: 10.0.0.0
      Transformation rule:
      e_set("long_ip",ip2long(v("ip")))
      Result:
      ip: 10.0.0.0
      long_ip: 167772160
    • Example 2: An invalid IP address is passed to the function.
      Raw log entry:
      ip: 333.1.1.1
      Transformation rule:
      e_set("long_ip",ip2long(v("ip"), "ignore"))
      Result:
      ip: 333.1.1.1
      long_ip: 0

long2ip

  • Syntax
    long2ip(value,default="")
  • Parameters
    Parameter Data Type Required Description
    Value String Yes The value to be decoded.
    default String No The string to which an invalid LONG value is converted. You can customize the value of this parameter. Default value: empty string.
  • Response:

    The IP address converted from a valid LONG value.

  • Examples
    • Example 1: A valid IP address is passed to the function.
      Raw log entry:
      long: 167772160
      Transformation rule:
      e_set("ip",long2ip(v("long")))
      Result:
      long: 167772160
      ip: 10.0.0.0
    • Example 2: An invalid Long value is passed to the function, and the default parameter is not specified.
      Raw log entry:
      long: 4294967296
      Transformation rule:
      e_set("ip",long2ip(v("long")))
      Result:
      long: 4294967296
      ip: 
    • Example 3: An invalid LONG value is passed to the function, and the default parameter is specified.
      Raw log entry:
      long: 4294967296
      Transformation rule:
      e_set("ip",long2ip(v("long"),default="xxx"))
      Result:
      long: 4294967296
      ip: xxx