This topic describes the syntax and parameters of encoding and decoding functions. This topic also provides examples on how to use the functions.

Functions

Type Function Description
URL url_encoding Encodes URL data.
url_decoding Decodes URL data.
Base64 base64_encoding Encodes data by using the Base64 algorithm.
base64_decoding Decodes data by using the Base64 algorithm.
HTML html_encoding Encodes data in the HTML format.
html_decoding Decodes HTML-encoded data.
MD5 md5_encoding Encodes data by using the MD5 algorithm.
SHA1 sha1_encoding Encodes data by using the SHA1 algorithm.
IP address ip2long Converts an IP address to a value of the long type.
long2ip Converts a value of the long type to an IP address.
AES aes_encrypt Encrypts data by using the AES algorithm.
aes_decrypt Decrypts data by using the AES algorithm.

url_encoding

The url_encoding function is used to encode URL data.

  • Syntax
    url_encoding(Value)
  • Parameters
    Parameter Type Required Description
    Value String Yes The value that you want to encode.
  • 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

The url_decoding function is used to decode URL data.

  • Syntax
    url_decoding(Value)
  • Parameters
    Parameter Type Required Description
    Value String Yes The value that you want to decode.
  • 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

The base64_encoding function is used to encode data by using the Base64 algorithm.

  • Syntax
    base64_encoding(Value,format=None)
  • Parameters
    Parameter Type Required Description
    Value String Yes The value that you want to encode.
    format String No The Base64 encoding scheme. Valid values: RFC 3548 and RFC 4648. Default value: RFC 3548.
  • 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

The base64_decoding function is used to decode data by using the Base64 algorithm.

  • Syntax
    base64_decoding(Value,format=None)
  • Parameters
    Parameter Type Required Description
    Value String Yes The value that you want to decode.
    format String No The Base64 decoding scheme. Valid values: RFC 3548 and RFC 4648. Default value: RFC 3548.
    Note The Base64 decoding scheme in RFC 4648 uses an equal sign (=) to convert a decoded value to a multiple of 4 bytes.
  • 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

The html_encoding function is used to encode data in the HTML format.

  • Syntax
    html_encoding(Value)
  • Parameters
    Parameter Type Required Description
    Value String Yes The value that you want to encode.
  • 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

The html_decoding function is used to decode HTML-encoded data.

  • Syntax
    html_decoding(Value)
  • Parameters
    Parameter Type Required Description
    Value String Yes The value that you want to decode.
  • 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

The md5_encoding function is used to encode data by using the MD5 algorithm.

  • Syntax
    md5_encoding(Value,format="hex")
  • Parameters
    Parameter Type Required Description
    Value String Yes The value that you want to encode.
    format String No Valid values: binary and hex. Default value: hex.
  • Response

    An MD5 hash value is returned.

  • Examples
    • Example 1
      • Raw log entry:
        str : GeeksforGeeks
      • Transformation rule:
        e_set("str_md5_en",md5_encoding(v("str")))
      • Result:
        str : GeeksforGeeks
        str_md5_en : f1e069787ece74531d112559945c6871
    • Example 2
      • Raw log entry:
        str : GeeksforGeeks
      • Transformation rule:
        e_set("str_md5_en",base64_encoding(md5_encoding(v("str"), format="binary")))
      • Result:
        str : GeeksforGeeks
        str_md5_en : 8eBpeH7OdFMdESVZlFxocQ==

sha1_encoding

The sha1_encoding function is used to encode data by using the SHA1 algorithm.

  • Syntax
    sha1_encoding(Value,format=None)
  • Parameters
    Parameter Type Required Description
    Value String Yes The value that you want to encode.
    format String No The SHA algorithm. Valid values: SHA1, SHA224, SHA256, SHA384, and SHA512. Default value: SHA1.
  • 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

The ip2long function is used to convert an IP address to a value of the long type.

  • Syntax
    ip2long(Value,default=0)
  • Parameters
    Parameter Type Required Description
    Value String Yes The value that you want to convert.
    default String No The value that is converted from an invalid IP address. User-defined values are supported, for example, 0.
  • Response

    The value that is converted from a valid IP address is returned. The value is of the long type.

  • Examples
    • Example 1: Convert a valid IP address.
      • 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: Convert an invalid IP address.
      • 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:ignore

long2ip

The long2ip function is used to convert a value of the long type to an IP address.

  • Syntax
    long2ip(Value,default="")
  • Parameters
    Parameter Type Required Description
    Value String Yes The value that you want to convert.
    default String No The string that is converted from an invalid value of the long type. User-defined strings are supported.
  • Response

    The IP address that is converted from a valid value of the long type is returned.

  • Examples
    • Example 1: Convert a valid value of the long type.
      • Raw log entry:
        long: 167772160
      • Transformation rule:
        e_set("ip",long2ip(v("long")))
      • Result:
        long: 167772160
        ip: 10.0.0.0
    • Example 2: Convert an invalid value of the long type.
      • Raw log entry:
        long: 4294967296
      • Transformation rule:
        e_set("ip",long2ip(v("long")))
      • Result:
        long: 4294967296
        ip: 
    • Example 3: Set the default parameter to a user-defined string for an invalid value of the long type.
      • Raw log entry:
        long: 4294967296
      • Transformation rule:
        e_set("ip",long2ip(v("long"),default="xxx"))
      • Result:
        long: 4294967296
        ip: xxx

aes_encrypt

The aes_encrypt function is used to encrypt data by using the AES algorithm. The Advanced Encryption Standard (AES) algorithm is the most common symmetric encryption algorithm. To ensure data security, you can use the AES algorithm to encrypt data.

  • Syntax
    aes_encrypt(data,key,mode,pad_style,pad_block,input_format,input_encoding,output_format,iv)
  • Parameters
    Parameter Type Required Description
    data String Yes The data that you want to encrypt.
    key String Yes The key that you want to use for data encryption.
    mode String No The encryption mode of the AES algorithm.
    • CBC (default): Cipher Block Chaining
    • ECB: Electronic Codebook Book
    • CFB: Cipher Feedback
    • OFB: Output Feedback
    • CTR: Counter
    • OPENPGP
    pad_style String No The padding mode. Default value: pkcs7. Valid values: iso7816, x923, and pkcs7.
    input_format String No The format of characters. Default value: raw. Valid values:
    • raw: bytes
    • hex: hexadecimal
    • Base64: Base64 encoding format
    input_encoding String No The encoding format. This parameter is required only if you set the input_format parameter to raw. Default value: uft-8.
    output_format String No The format of characters. Default value: hex. Valid values:
    • raw: bytes
    • hex: hexadecimal
    • Base64: Base64 encoding format
    iv Bytes No The offset that is used for encryption.
  • Response

    The string that is encrypted from a value by using the AES algorithm is returned.

  • Examples
    • Example 1
      • Raw log entry:
        "test": "aliyuntest"
      • Transformation rule:
        e_set('result',aes_encrypt(v("test"), "qwertyuiopasdfgd", iv=b"xxywosjdapdiawdk", output_format="base64"))
      • Result:
        "result": "gXIqu0cBBtZHQxJBK8GLeA=="
    • Example 2
      • Raw log entry:
        "test": "aliyuntest"
      • Transformation rule:
        e_set('result',aes_encrypt(v("test"), "qwertyuiopasdfgh", iv=b"ywisnjaduaqibdqi", mode="OFB"))
      • Result:
        "result":  "5cac3e9e1c42f713dc6d"

aes_decrypt

The aes_decrypt function is used to decrypt encrypted data by using the AES algorithm.

  • Syntax
    aes_decrypt(data,key,mode,pad_style,input_format,input_encoding,output_format,iv,output_encoding)
  • Parameters
    Parameter Type Required Description
    data String Yes The data that you want to decrypt.
    key String Yes The key that you want to use for data decryption.
    mode String No The decryption mode of the AES algorithm.
    • CBC (default): Cipher Block Chaining
    • ECB: Electronic Codebook Book
    • CFB: Cipher Feedback
    • OFB: Output Feedback
    • CTR: Counter
    • OPENPGP
    pad_style String No The padding mode. Default value: pkcs7. Valid values: iso7816, x923, and pkcs7.
    input_format String No The format of characters. Default value: hex. Valid values:
    • raw: bytes
    • hex: hexadecimal
    • Base64: Base64 encoding format
    input_encoding String No The encoding format. This parameter is required only if you set the input_format parameter to raw. Default value: uft-8.
    output_format String No The format of characters. Default value: raw. Valid values:
    • raw: bytes
    • hex: hexadecimal
    • Base64: Base64 encoding format
    iv Bytes No The offset that is used for decryption.
    output_encoding String No The encoding format. Default value: None.
  • Response

    The string that is decrypted from a value by using the AES algorithm is returned.

  • Examples
    • Example 1
      • Raw log entry:
        "test": "gXIqu0cBBtZHQxJBK8GLeA=="
      • Transformation rule:
        e_set('result', aes_decrypt(v("test"), "qwertyuiopasdfgd", iv=b"xxywosjdapdiawdk", input_format="base64"))
      • Result:
        "result": "aliyuntest"
    • Example 2
      • Raw log entry:
        "test": "5cac3e9e1c42f713dc6d"
      • Transformation rule:
           e_set('result', aes_decrypt(v("test"), "qwertyuiopasdfgh", iv=b"ywisnjaduaqibdqi", mode="OFB"))
      • Result:
        "result": "aliyuntest"