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 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 long value. |
long2ip | Converts a long value to an IP address. |
url_encoding
Use the url_encoding function to encode URL data.
- 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.
- Examples
- 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
- Raw log entry:
url_decoding
Use the url_decoding function to decode URL data.
- 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.
- Examples
- 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
- Raw log entry:
base64_encoding
Use the base64_encoding function to encode data.
- Syntax
base64_encoding(Value,format=None)
- Parameters
Parameter Data type Required Description Value String Yes The value to be encoded. 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.
- Examples
- 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
- Raw log entry:
base64_decoding
Use the base64_decoding function to decode data.
- Syntax
base64_encoding(Value,format=None)
- Parameters
Parameter Data type Required Description Value String Yes The value to be decoded. format String Yes The Base64 decoding scheme. Valid values: RFC 3548 and RFC 4648. Default value: RFC 3548. Note Base64 decoding in RFC 4648 uses an equal sign (=) to populate a decoded value to a multiple of 4 bytes. - Result:
A Base64-decoded string is returned.
- Examples
- 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
- Raw log entry:
html_encoding
Use the html_encoding function to encode data.
- 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.
- Examples
- 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 : <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" />
- Raw log entry:
html_decoding
Use the html_decoding function to decode data.
- 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.
- Examples
- 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_de",html_decoding(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_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" />
- Raw log entry:
md5_encoding
Use the md5_encoding function to encode data.
- Syntax
md5_encoding(Value,format="hex")
- Parameters
Parameter Data type Required Description Value String Yes The value to be encoded. 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
- Raw log entry:
- 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==
- Raw log entry:
- Example 1
sha1_encoding
Use the sha1_encoding function to encode data.
- 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. Valid values: SHA1, SHA224, SHA256, SHA384, and SHA512. Default value: SHA1. - Result:
A SHA1-encoded string is returned.
- Examples
- 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
- Raw log entry:
ip2long
Use the ip2long function to convert an IP address to a long value.
- Syntax
ip2long(Value,default=0)
- Parameters
Parameter Data type Required Description Value String Yes The value to be decoded. default String No The long value converted from an invalid IP address. User-defined values are supported, for example, 0. - Response
The long value converted from a valid IP address is returned.
- 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
- Raw log entry:
- 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: 0
- Raw log entry:
- Example 1: Convert a valid IP address.
long2ip
Use the long2ip function to convert a long value to an IP address.
- Syntax
long2ip(value,default="")
- Parameters
Parameter Date type Required Description Value String Yes The value to be decoded. default String No The string converted from an invalid long value. User-defined strings are supported. - Response
The IP address converted from a valid long value.
- Examples
- Example 1: Convert a valid long value.
- Raw log entry:
long: 167772160
- Transformation rule:
e_set("ip",long2ip(v("long")))
- Result:
long: 167772160 ip: 10.0.0.0
- Raw log entry:
- Example 2: Convert an invalid long value.
- Raw log entry:
long: 4294967296
- Transformation rule:
e_set("ip",long2ip(v("long")))
- Result:
long: 4294967296 ip:
- Raw log entry:
- Example 3: User-defined strings are set for the invalid IP address.
- Raw log entry:
long: 4294967296
- Transformation rule:
e_set("ip",long2ip(v("long"),default="xxx"))
- Result:
long: 4294967296 ip: xxx
- Raw log entry:
- Example 1: Convert a valid long value.