All Products
Search
Document Center

Simple Log Service:Encoding and decoding functions

Last Updated:Aug 26, 2026

Encoding and decoding functions encode, decode, compress, encrypt, and hash field values in a data transformation job. The following sections describe the syntax, parameters, return value, and examples of each function.

Function list

Type

Subcategory

Function

Description

Encoding and decoding

String

str_encode

Encodes data.

Encoding and decoding

String

str_decode

Decodes data.

Encoding and decoding

Base64

base64_encoding

Encodes data by using Base64.

Encoding and decoding

Base64

base64_decoding

Decodes Base64-encoded data.

Encoding and decoding

HTML

html_encoding

Encodes data by using HTML encoding.

Encoding and decoding

HTML

html_decoding

Decodes HTML-encoded data.

Encoding and decoding

URL

url_encoding

Encodes data by using URL encoding.

Encoding and decoding

URL

url_decoding

Decodes URL-encoded data.

Encoding and decoding

Protobuf

protobuf_decoding

Parses data into JSON format based on the Protobuf template that you specify.

Encoding and decoding

JSON Web Token (JWT)

jwt_encoding

Encodes JSON data based on the JSON Web Token (JWT) standard.

Encoding and decoding

JSON Web Token (JWT)

jwt_decoding

Decodes data into the original JSON based on the JSON Web Token (JWT) standard.

Encoding and decoding

Hashids

hashids_encoding

Encodes data by using the Hashids library.

Encoding and decoding

Hashids

hashids_decoding

Decodes data that was encoded by using the Hashids library.

Compression and decompression

Gzip

gzip_compress

Compresses data and encodes the result in Base64 or hex format.

Compression and decompression

Gzip

gzip_decompress

Decompresses Base64-encoded or hex-encoded data.

Compression and decompression

Zlib

zlib_compress

Compresses data and encodes the result in Base64 format.

Compression and decompression

Zlib

zlib_decompress

Decompresses Base64-encoded data.

Encryption and decryption

Advanced Encryption Standard (AES)

aes_encrypt

Encrypts data by using AES.

Encryption and decryption

Advanced Encryption Standard (AES)

aes_decrypt

Decrypts AES-encrypted data.

Hash

MD5

md5_encoding

Calculates the MD5 hash of data.

Hash

SHA1

sha1_encoding

Calculates the SHA-1 hash of data.

Hash

Cyclic redundancy check (CRC)

crc32_encoding

Calculates the CRC-32 checksum of data.

str_encode

Encodes the string using the specified encoding format.

  • Syntax

    str_encode(value, "utf8", errors="ignore")
  • Parameters

    Parameter

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The value to encode.

    encoding

    String

    No

    The encoding format. Default value: UTF-8. ASCII is supported.

    errors

    String

    No

    The method that is used to process characters if the characters cannot be recognized based on the encoding format. Valid values:

    • ignore (default): The characters are not encoded.

    • strict: An error is reported, and the log is discarded.

    • replace: The unrecognizable characters are replaced with question marks (?).

    • xmlcharrefreplace: The unrecognizable characters are replaced with XML characters.

  • Response

    Returns an encoded string.

  • Examples

    • Example 1

      • Raw log

        test: asewds
      • Transformation rule

        e_set("f1", str_decode(str_encode("Hello", "utf8"), "utf8"))
      • Result

        test: asewds
        f1: Hello
    • Example 2

      • Raw log

        f2: test Test data
      • Transformation rule

        e_set("f1", str_encode(v("f2"), "ascii", errors="ignore"))
      • Result

        f1:test 
        f2:test Test data
    • Example 3

      • Raw log

        f2: test data
      • Transformation rule

        e_set("f1", str_encode(v("f2"), "ascii", errors="strict"))
      • Result

        An error is reported during execution.

    • Example 4

      • Raw log

        f2: test Test data
      • Transformation rule

        e_set("f1", str_encode(v("f2"), "ascii", errors="replace"))
      • Result

        f1:test ????
        f2:test Test data
    • Example 5

      • Raw log

        f2: test Test data
      • Transformation rule

        e_set("f1", str_encode(v("f2"), "ascii", errors="xmlcharrefreplace"))
      • Result

        f1:test 测试数据
        f2:test Test data

str_decode

Decodes the input value using the specified encoding format.

  • Syntax

    str_decode(value, "utf8", errors="ignore")
    Note

    The str_decode function can process only the data of the byte data type.

  • Parameters

    Parameter Name

    Data Types

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The value to decode.

    encoding

    Arbitrary (auto-converted to string)

    No

    The encoding format. Default value: UTF-8. ASCII is supported.

    errors

    Arbitrary (auto-converted to string)

    No

    The method that is used to process characters if the characters cannot be recognized based on the encoding format. Valid values:

    • ignore (default): The characters are not decoded.

    • strict: An error is reported, and the log is discarded.

    • replace: The unrecognizable characters are replaced with question marks (?).

    • xmlcharrefreplace: The unrecognizable characters are replaced with XML characters.

  • Response

    Returns a decoded value.

  • Examples

    • Raw log

      test: asewds
    • Transformation rule

      e_set("encoding", str_decode(b'\xe4\xbd\xa0\xe5\xa5\xbd', "utf8", 'strict'))
    • Result

      test: asewds
      encoding: Hello

base64_encoding

Encodes data by using Base64.

Syntax

base64_encoding(value, format=None)

Parameters

Parameter

Type

Required

Description

value

String

Yes

The value to encode.

format

String

No

The Base64 encoding scheme. Default value:RFC3548. Valid values: RFC3548 andRFC4648.

Response

Returns the encoded string.

Examples

  • Example: Encode the value of the str_en field.

    • Raw log

      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

Decodes Base64-encoded data.

Syntax

base64_decoding(value, format=None)

Parameters

Parameter

Type

Required

Description

value

String

Yes

The value to decode.

format

String

No

The Base64 decoding scheme. Default value:RFC3548. Valid values: RFC3548 andRFC4648.

Note

The RFC4648 Base64 decoding scheme uses equal signs (=) to pad the value to be decoded to a multiple of four bytes. |

Response

Returns the decoded string.

Examples

  • Example: Decode the value of the str_de field.

    • Raw log

      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

Encodes data by using HTML encoding.

Syntax

html_encoding(value)

Parameters

Parameter

Type

Required

Description

value

String

Yes

The value to encode.

Response

Returns the encoded string.

Examples

  • Example: Encode the value of the str field.

    • Raw log

      str : <img class="size-medium wp-image-113" style="margin-left: 15px;" title="su1" src="http://aliyundoc.com/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://aliyundoc.com/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://aliyundoc.com/wp-content/uploads/2008/10/su1-300x194.jpg&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;194&quot; /&gt;

html_decoding

Decodes HTML-encoded data.

Syntax

html_decoding(value)

Parameters

Parameter

Type

Required

Description

value

String

Yes

The value to decode.

Response

Returns the decoded string.

Examples

  • Example: Decode the value of the str field.

    • Raw log

      str : &lt;img class=&quot;size-medium wp-image-113&quot; style=&quot;margin-left: 15px;&quot; title=&quot;su1&quot; src=&quot;http://aliyundoc.com/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://aliyundoc.com/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://aliyundoc.com/wp-content/uploads/2008/10/su1-300x194.jpg" alt="" width="300" height="194" />

url_encoding

Encodes data by using URL encoding.

Syntax

url_encoding(value, plus=False)

Parameters

Parameter

Type

Required

Description

value

String

Yes

The value to encode.

plus

Boolean

No

Specifies whether to convert spaces to plus signs (+). Default value: False. Valid values:

  • True: Converts spaces to plus signs (+).

  • False: Does not convert spaces to plus signs (+). |

Response

Returns the encoded string.

Examples

  • Example 1: URL-encode data.

    • Raw log

      content: https://www.example.org/hello/asdah
    • Transformation rule

      e_set("URL",url_encoding(v("content")))
    • Result

      content: https://www.example.org/hello/asdah
      URL: https%3A%2F%2Fwww.example.org%2Fhello%2Fasdah
  • Example 2: URL-encode data. In this example, theplus parameter is not specified, so spaces in the data are not converted to plus signs.

    • Raw log

      content: 1 2+3:4
    • Transformation rule

      e_set("URL",url_encoding(v("content")))
    • Result

      content: 1 2+3:4
      URL: 1%202%2B3%3A4
  • Example 3: URL-encode data. In this example, theplus parameter is set to True, so spaces in the data are converted to plus signs.

    • Raw log

      content: 1 2+3:4
    • Transformation rule

      e_set("URL", url_encoding(v("content"), plus=True))
    • Result

      content: 1 2+3:4
      URL: 1+2%2B3%3A4

url_decoding

Decodes URL-encoded data.

Syntax

url_decoding(value, plus=False)

Parameters

Parameter

Type

Required

Description

value

String

Yes

The value to decode.

plus

Boolean

No

Specifies whether to convert plus signs (+) to spaces. Default value: False. Valid values:

  • True: Converts plus signs (+) to spaces.

  • False: Does not convert plus signs (+) to spaces. |

Response

Returns the decoded string.

Examples

  • Example 1: URL-decode data.

    • Raw log

      content : https%3A%2F%www.example.org%2FHello%2Fasdah
    • Transformation rule

      e_set("URL",url_decoding(v("content")))
    • Result

      content : https%3A%2F%www.example.org%2FHello%2Fasdah
      URL : https://www.example.org/Hello/asdah
  • Example 2: URL-decode data. In this example, theplus parameter is not specified, so plus signs (+) in the data are not converted to spaces.

    • Raw log

      content : /answer?event_date=2022-06-30+09%3A06%3A53%20123
    • Transformation rule

      e_set("URL",url_decoding(v("content")))
    • Result

      content:/answer?event_date=2022-06-30+09%3A06%3A53%20123
      URL:/answer?event_date=2022-06-30+09:06:53 123
  • Example 3: URL-decode data. In this example, theplus parameter is set to True, so plus signs (+) in the data are converted to spaces.

    • Raw log

      content : /answer?event_date=2022-06-30+09%3A06%3A53%20123
    • Transformation rule

      e_set("URL",url_decoding(v("content"),plus=True))
    • Result

      content:/answer?event_date=2022-06-30+09%3A06%3A53%20123
      URL:/answer?event_date=2022-06-30 09:06:53 123

protobuf_decoding

Parses data into JSON format based on the Protobuf template that you specify.

Syntax

protobuf_decoding(data, protocol, input_format="bytes", message_name=None)

Parameters

Parameter

Type

Required

Description

data

String

Yes

The Protobuf-serialized data.

protocol

String

Yes

The Protobuf template data.

input_format

String

No

The data format. Default value: bytes. Valid values:

  • hex: hexadecimal format

  • bytes (default): byte format

  • raw: byte format

  • base64: Base64 encoding format |

    |message_name |String |No |The name of the message to retrieve. |

Response

If message_name is not specified, a list of JSON data is returned. If message_name is specified, a JSON data object is returned.

Examples

  • Example 1: Use a template to parse Base64-encoded Protobuf data into JSON format.

    • Raw log

      {
        "protocol": 'syntax = "proto3"; message Person {  string name = 1;  int32 id = 2; string email = 3;}  ',
        "data": "Cgl4aWFvIG1pbmcQARoOMTIzMTIzQDEyMy5jb20="
      }
    • Transformation rule

      e_set("data", protobuf_decoding(v("data"), v("protocol"), "base64", "Person"))
    • Result

      data:{
        "name": "xiao ming",
        "id": 1,
        "email": "123123@123.com"
      }
      protocol:syntax = "proto3"; message Person {  string name = 1;  int32 id = 2; string email = 3;}
  • Example 2: Obtain the template from advanced parameters and then parse the Protobuf data into JSON format.

    • Raw log

      {
          "data": "Cgl4aWFvIG1pbmcQARoOMTIzMTIzQDEyMy5jb20="
      }
    • Transformation rule

      e_set("data",
            protobuf_decoding(
                v("data"),
                res_local("protocol"),
                "base64",
                "Person"
            )
      )
    • Advanced parameter settings

    In theCreate a data transformation job panel, configure advanced parameters. For this example, setkey toprotocol andvalue tosyntax = "proto3"; message Person { string name = 1; int32 id = 2; string email = 3;}.

  • Result

    data:{
      "name": "xiao ming",
      "id": 1,
      "email": "123123@123.com"
    }
  • Example 3: Obtain the template from an OSS file and then parse the Protobuf data into JSON format.

    • Raw log

      {
          "data": "Cgl4aWFvIG1pbmcQARoOMTIzMTIzQDEyMy5jb20="
      }
    • OSS file content

      syntax = "proto3"; message Person {  string name = 1;  int32 id = 2; string email = 3;}
    • Transformation rule

      e_set(
          "protocol",
          res_oss_file(
              endpoint="http://oss-cn-chengdu.aliyuncs.com",
              ak_id="your_ak_id",
              ak_key="your_ak_key",
              bucket="test-protobuf",
              file="test.json",
          ),
      )
      e_set("data", protobuf_decoding(v("data"), v("protocol"), "base64", "Person"))
    • Result

      data:{
        "name": "xiao ming",
        "id": 1,
        "email": "123123@123.com"
      }
      protocol:syntax = "proto3"; message Person {  string name = 1;  int32 id = 2; string email = 3;}

jwt_encoding

Encodes JSON data based on the JSON Web Token (JWT) standard.

Note

JSON Web Token (JWT) is an open standard (RFC7519) that provides a compact and self-contained method for securely transmitting information between parties as a JSON object. Its digital signature makes the information verifiable and trustworthy. A JWT can be signed with a secret (using an HMAC algorithm) or with a public and private key pair (using RSA or ECDSA). For more information, seeJWT Introduction.

Syntax

jwt_encoding(payload, key, algorithms="HS256", headers=None)

Parameters

Parameter

Type

Required

Description

payload

JSON

Yes

The data to encode, in JSON format. The JWT standard defines the following seven fields. You can also define custom fields:

  • iss: issuer. The entity that issued the token.

  • exp: expiration time. The time when the token expires.

  • sub: subject. The subject of the token.

  • aud: audience. The intended recipients of the token.

  • nbf: Not Before. The time when the token takes effect.

  • iat: Issued At. The time when the token was issued.

  • jti: JWT ID. The unique identifier of the token. The following example shows the raw JSON data:

    {
        "iss": "localhost",
        "sub": "name",
        "aud": "user",
        "address": {
            "street": "street number",
            "city": "hangzhou",
            "country": "china"
        }
    }

    | |key |String |Yes |The key used to encrypt the JWT data. The key depends on the selected encryption algorithm:

  • Asymmetric encryption algorithm: a PEM-encoded private key.

  • Symmetric encryption algorithm: the key itself. |

    |algorithms |String |No |The algorithm used to sign the token. Default value: HS256. The following algorithms are supported:HS256,HS384,HS512,ES256,ES256K,ES384,ES512,RS256,RS384,RS512,PS256,PS384,PS512,EdDSA. | |headers |JSON |No |The JWT encoding header. Default value:

{
    "typ": "JWT",
    "alg": "HS256"
}

|

Response

Returns the encoded string.

Examples

  • Example 1: Encode the value of the data log field.

    • Raw log

      data: {"some": "payload"}
    • Transformation rule

      e_set("jwt_token", jwt_encoding(v("data"),"secret", algorithms="HS256"))
    • Result

      data:{"some": "payload"}
      jwt_token:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzb21lIjoicGF5bG9hZCJ9.Joh1R2dYzkRvDkqv3sygm5YyK8Gi4ShZqbhK2gxcs2U
  • Example 2: Encode the value of the data log field by using an asymmetric encryption algorithm.

    • Raw log

      data: {"some": "payload"}
    • Transformation rule

      e_set(
          "jwt_token",
          jwt_encoding(
              v("data"),
              "-----BEGIN RSA PRIVATE KEY-----\nMIICYQIBAAKBgQC1iaUr5cgShCn0127+w14XN297q/IviaewIeIJsKTZF1hBPsLn\nNIPsnqtQ9DFbjIyqyZvdmQFDJCSLpXaVc648yepnFDKbOfs3r+K4Crnpo2SuZmNV\nNDVEi4pECXlBz810zJY1wqVArM7qGAyCcRLBprwXB6wfEhk3CAP3c29+pwIDAQAB\nAoGAARo65I9arbIbxx7fz7BEDAQMK0YaDGvbltg91S07cw4PPSYybNEG1BMKm01A\nV3v9BrR+u9PIDC5WAnsYwiODqEoSyk8OwO1E2kWA6+MNclYYfVjaJeiRJ5PzCud/\niUObonptRzxuTng+u1oGuX7QwUhwGJdXVBUAtJFYwXR2qVECRQC5S+6vdFESRLSX\n7yBZVM6+49lZcdehMv0HwT17UseLvWcjeSbiogvv02HbYilrW9ZydKsixAWP5w/U\nS3L34CS811VcDQI9APrOiL7c1xg5fX8wAWv2d+e+MfZoB3ohb8671W3pmp3JVnjY\ntzhoYNNQmnmRQQWf7n3J63MQz4sYYNn0gwJEE/pl37Dw1MFnn0H/AOKt79LtKkGl\n+BFhSqbBFDzWmvBu4Fo9oQ3Lr63gzSCGSrb6JhkCIptz5hIJmOARozwdeebVozkC\nPQDwOqVmU3c/P8nB6oRiGditw1Jt1yTaSW6jkOyUc73iRngqFkIgqHGd1kWwDX4/\nWfoAyEhalY6Fh5s1COsCRQCy4b3hnQws5zz/gmGNnoyxn9N+A09ySaFtn2WkUlrR\nZ6DwoJz+n6EgjLY8z6ZQyv342iobO5zKkZHFvO9QYGqk7y8lJA==\n-----END RSA PRIVATE KEY-----\n",
              algorithms="RS256",
          ),
      )
    • Result

      data:{"some": "payload"}
      jwt_token:eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzb21lIjoicGF5bG9hZCJ9.Ewwls5YPuJCmAR3XR2tcptOLrH83wVCzmUaUpGMzMLcPknRrIvbDmFGlNlQha-PMx0jsxt3t1oxpz7P3z3SR9o4qyWusAb99UG_Jn8oP8W0a5GKSy4UEJB0xgpVvJl5F2JaIPeUSHpV0VeS2WAsGSBBSAaOMkrc-8uie-H4J9M0
  • Example 3: Encode the value of the data log field, specify HS256 as the signature algorithm, and specify headers.

    • Raw log

      data: {"some": "payload"}
    • Transformation rule

      e_set(
          "jwt_token",
          jwt_encoding(
              v("data"),
              "secret",
              algorithms="HS256",
              headers={"kid": "230498151c214b788dd97f22b85410a5"},
          ),
      )
    • Result

      data:{"some": "payload"}
      jwt_token:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6IjIzMDQ5ODE1MWMyMTRiNzg4ZGQ5N2YyMmI4NTQxMGE1In0.eyJzb21lIjoicGF5bG9hZCJ9.gdQ884yjlnLnIrYjfQaClE6rJC2x8v2OP2s_eXOLhZA
  • Example 4: Specify custom JWT fields for the value of the data log field and then encode it.

    • Raw log

      data: {"some": "payload", "iss": 9, "sub": "name", "nbf": 123, "iat": "22"}
    • Transformation rule

      e_set("jwt_token", jwt_encoding(v("data"),"secret"))
    • Result

      data:{"some": "payload", "iss": 9, "sub": "name", "nbf": 123, "iat": "22"}
      jwt_token:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzb21lIjoicGF5bG9hZCIsImlzcyI6OSwic3ViIjoibmFtZSIsIm5iZiI6MTIzLCJpYXQiOiIyMiJ9.c6MxZHdXsgASchQ1Mdqj208NO_3rNGjYnvo6c7HNAyk

jwt_decoding

Decodes data into the original JSON based on the JSON Web Token (JWT) standard.

Syntax

jwt_decoding(jwt_payload, key="", algorithms=None, options=None, audience=None, issuer=None, leeway=0)

Parameters

Parameter

Type

Required

Description

jwt_payload

String

Yes

The value to decode.

key

String

Yes

The key used to decrypt the data. The key must be the same as the key used for encoding.

algorithms

List

No

The algorithm used to sign the token, such as HS256.

options

JSON

No

The extended decoding and validation options. The options include:

  • verify_signature: specifies whether to verify the JWT signature. Default value: True.

  • require: the fields that must exist in the encoded data. This option is empty by default. Example:["exp", "iat", "nbf"].

  • verify_aud: specifies whether to check the aud field. Default value: True.

  • verify_iss: specifies whether to check the iss field. Default value: True.

  • verify_exp: specifies whether to check the exp field. Default value: True.

  • verify_iat: specifies whether to check the iat field. Default value: True.

  • verify_nbf: specifies whether to check the nbf field. Default value: True. Example:{"require": ["aud"], "verify_aud": True}. |

    |audience |String/List |No |The value used to check aud.If you set the aud parameter during encoding and set"require": ["aud"] or"verify_aud": True in the options extension, you must specify this parameter during decoding. | |issuer |String |No |The value used to check iss.If you set the iss parameter during encoding and set"require": ["iss"] or"verify_iss": True in the options extension, you must specify this parameter during decoding. | |leeway |float |No |The time interval, in seconds, for expiration checks. |

Response

Returns the decoded string.

Examples

  • Example 1: Decode the value of the data log field and specify HS256 as the signature algorithm for decryption.

    • Raw log

      data:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzb21lIjoicGF5bG9hZCJ9.Joh1R2dYzkRvDkqv3sygm5YyK8Gi4ShZqbhK2gxcs2U
    • Transformation rule

      e_set("data_decoded", jwt_decoding(v("data"), "secret", algorithms="HS256"))
    • Result

      data_decoded: {"some": "payload"}
  • Example 2: Use a public key to decode the value of the data log field.

    • Raw log

      data: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzb21lIjoicGF5bG9hZCJ9.Ewwls5YPuJCmAR3XR2tcptOLrH83wVCzmUaUpGMzMLcPknRrIvbDmFGlNlQha-PMx0jsxt3t1oxpz7P3z3SR9o4qyWusAb99UG_Jn8oP8W0a5GKSy4UEJB0xgpVvJl5F2JaIPeUSHpV0VeS2WAsGSBBSAaOMkrc-8uie-H4J9M0"
    • Transformation rule

      e_set(
          "data_decoded",
          jwt_decoding(
              v("data"),
              "-----BEGIN RSA PUBLIC KEY-----\nMIGJAoGBALWJpSvlyBKEKfTXbv7DXhc3b3ur8i+Jp7Ah4gmwpNkXWEE+wuc0g+ye\nq1D0MVuMjKrJm92ZAUMkJIuldpVzrjzJ6mcUMps5+zev4rgKuemjZK5mY1U0NUSL\nikQJeUHPzXTMljXCpUCszuoYDIJxEsGmvBcHrB8SGTcIA/dzb36nAgMBAAE=\n-----END RSA PUBLIC KEY-----\n",
              algorithms="RS256",
          ),
      )
    • Result

      data:"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzb21lIjoicGF5bG9hZCJ9.Ewwls5YPuJCmAR3XR2tcptOLrH83wVCzmUaUpGMzMLcPknRrIvbDmFGlNlQha-PMx0jsxt3t1oxpz7P3z3SR9o4qyWusAb99UG_Jn8oP8W0a5GKSy4UEJB0xgpVvJl5F2JaIPeUSHpV0VeS2WAsGSBBSAaOMkrc-8uie-H4J9M0"
      data_decoded: {"some": "payload"}
  • Example 3: Decode the value of the data log field by using the default extended decoding and validation options.

    • Raw log

      data: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzb21lIjoicGF5bG9hZCIsImlzcyI6OSwic3ViIjoibmFtZSIsIm5iZiI6MTIzLCJpYXQiOiIyMiJ9.DzvqhJd0PrTFk6eeASGZxOoDtrLBt_H3xC7CqOATRRw"
    • Transformation rule

      e_set(
          "data_decoded", jwt_decoding(v("data"), "secret", algorithms="HS256", options=None)
      )
    • Result

      data:"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzb21lIjoicGF5bG9hZCIsImlzcyI6OSwic3ViIjoibmFtZSIsIm5iZiI6MTIzLCJpYXQiOiIyMiJ9.DzvqhJd0PrTFk6eeASGZxOoDtrLBt_H3xC7CqOATRRw"
      data_decoded:{
              "some": "payload",
              "iss": 9,
              "sub": "name",
              "nbf": 123,
              "iat": "22"
          }
  • Example 4: Decode the value of the data log field and specify some extended decoding and validation options.

    • Raw log

      data: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzb21lIjoicGF5bG9hZCIsImlzcyI6Im5hbWUifQ.XwT9jqwofcdSP6olidbiYPC6CnZd36OEqCHZmGmooWM"
    • Transformation rule

      e_set(
          "data_decoded",
          jwt_decoding(
              v("data"),
              "secret",
              algorithms="HS256",
              options={"require": ["iss"], "verify_iss": True},
              issuer="name",
          ),
      )
    • Result

      data: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzb21lIjoicGF5bG9hZCIsImlzcyI6Im5hbWUifQ.XwT9jqwofcdSP6olidbiYPC6CnZd36OEqCHZmGmooWM"
      data_decoded:{"some": "payload", "iss": "name"}

hashids_encoding

Encodes data by using the Hashids library.

Syntax

hashids_encoding(value, salt="", min_length=0)

Parameters

Parameter

Type

Required

Description

value

Number, List, Tuple

Yes

The value to encode.If value is a number, it cannot be less than 0.

salt

String

No

The salt added to the data. Default value: an empty string.

min_length

Number

No

The minimum length of the generated hash value. Default value: 0.

Response

Returns the encoded string.

Examples

  • Example 1: Encode a number by using the default salt and minimum hash length.

    • Raw log

      content:test
    • Transformation rule

      e_set("hashid", hashids_encoding(123))
    • Result

      content:test
      hashid:Mj3
  • Example 2: Encode List data by using a custom salt.

    • Raw log

      content:test
    • Transformation rule

      e_set("hashid", hashids_encoding([123, 456], salt="test"))
    • Result

      content:test
      hashid:bpBHYO
  • Example 3: Encode List data by using a custom salt and minimum hash length.

    • Raw log

      content:test
    • Transformation rule

      e_set("hashid", hashids_encoding([123, 456], salt="test", min_length=32))
    • Result

      content:test
      hashid:O6jN0Z7VARqDzbpBHYOakeowE5Xnr41g
  • Example 4: Encode Tuple data by using a custom salt and minimum hash length.

    • Raw log

      content:test
    • Transformation rule

      e_set("hashid", hashids_encoding((123, 456), salt="test", min_length=32))
    • Result

      content:test
      hashid:O6jN0Z7VARqDzbpBHYOakeowE5Xnr41g

hashids_decoding

Decodes data that was encoded by using the Hashids library.

Syntax

hashids_decoding(hashid, salt="", min_length=0)

Parameters

Parameter

Type

Required

Description

hashid

String

Yes

The data to decode.

salt

String

No

The salt added to the data. Default value: an empty string.

min_length

Number

No

The minimum length of the generated hash value. Default value: 0.

Response

Returns the decoded string.

Examples

  • Example 1: Decode an encoded number by using the default salt and minimum hash length.

    • Raw log

      content:Mj3
    • Transformation rule

      e_set("value", hashids_decoding(v("content")))
    • Result

      content:Mj3
      value:[123]
  • Example 2: Decode encoded List data by using a custom salt and the default minimum hash length.

    • Raw log

      content:bpBHYO
    • Transformation rule

      e_set("value", hashids_decoding(v("content"), salt="test"))
    • Result

      content:bpBHYO
      value:[123, 456]
  • Example 3: Decode encoded List data by using a custom salt and minimum hash length.

    • Raw log

      content:O6jN0Z7VARqDzbpBHYOakeowE5Xnr41g
    • Transformation rule

      e_set("value", hashids_decoding(v("content"), salt="test", min_length=32))
    • Result

      content:O6jN0Z7VARqDzbpBHYOakeowE5Xnr41g
      value:[123, 456]
  • Example 4: Decode encoded Tuple data by using a custom salt and minimum hash length.

    • Raw log

      content:O6jN0Z7VARqDzbpBHYOakeowE5Xnr41g
    • Transformation rule

      e_set("value", hashids_decoding(v("content"), salt="test", min_length=32))
    • Result

      content:O6jN0Z7VARqDzbpBHYOakeowE5Xnr41g
      value:[123, 456]

gzip_compress

Compresses data and encodes the result in Base64 or hex format.

Syntax

gzip_compress(data, compresslevel=6, to_format="base64", encoding="utf-8")

Parameters

Parameter

Type

Required

Description

data

String

Yes

The data to compress.

compresslevel

Int

No

The compression level. Set this parameter to an integer from 0 to 9, where a larger value indicates a higher compression ratio and a lower compression speed. Default value: 6. Valid values:

  • 0: no compression.

  • 1: the fastest compression speed but the lowest compression ratio.

  • 9: the slowest compression speed but the highest compression ratio. |

    |to_format |String |No |The format used to encode the compressed data. Base64 and hex encoding are supported. | |encoding |String |No |The encoding format of the original, uncompressed data. Default value: utf-8.

Response

Returns the encoded string.

Examples

  • Example 1: Compress a log field and encode it by using Base64.

    • Raw log

      content: I always look forward to my holidays whether I travel or stay at home.
    • Transformation rule

      e_set("base64_encode_gzip_compress",gzip_compress(v("content"),to_format="base64"))
    • Result

      content: I always look forward to my holidays whether I travel or stay at home.
      base64_encode_gzip_compress: H4sIAA8JXl4C/xXK0QmAMAwFwFXeBO7RMQKNREx5kAZDtle/7wbES3rDyRsnoyQmklgNo1/ztzJN08BAhjzqYGCnNCS/tPR4AcgrnWVGAAAA
  • Example 2: Compress a log field and encode it by using hex.

    • Raw log

      content: H4sIAA8JXl4C/xXK0QmAMAwFwFXeBO7RMQKNREx5kAZDtle/7wbES3rDyRsnoyQmklgNo1/ztzJN08BAhjzqYGCnNCS/tPR4AcgrnWVGAAAA
    • Transformation rule

      e_set("hex_encode_gzip_compress", gzip_compress(v("content"), to_format="hex"))
    • Result

      content:H4sIAA8JXl4C/xXK0QmAMAwFwFXeBO7RMQKNREx5kAZDtle/7wbES3rDyRsnoyQmklgNo1/ztzJN08BAhjzqYGCnNCS/tPR4AcgrnWVGAAAA
      hex_encode_gzip_compress:1f8b08004a478c6202ff0dc1dd0e43301800d047aa65156e3ff52f4a2ba17649c43255194d4a9f9e73527c64007e2e2426e81485c35628c1c42616535079bc6405e5d1e92ef009b59c906786a879efe1c50fb55d6c5de44cb717b2dae6d4f103f8feecbf4f88a2a441bae618c679575d9bc0e306907876806c000000

gzip_decompress

Decompresses compressed data that is Base64-encoded or hex-encoded.

Syntax

gzip_decompress(data, from_format="base64", encoding="utf-8")

Parameters

Parameter

Type

Required

Description

data

Any

Yes

The data to decompress.

from_format

String

No

The encoding format of the data to decompress. Base64 and hex decoding are supported.

encoding

String

No

The encoding format of the original, uncompressed data. Default value: utf-8.

Response

Returns the decompressed object.

Examples

  • Example 1: Decompress a log field whose value is Base64-encoded.

    • Raw log

      content: H4sIAA8JXl4C/xXK0QmAMAwFwFXeBO7RMQKNREx5kAZDtle/7wbES3rDyRsnoyQmklgNo1/ztzJN08BAhjzqYGCnNCS/tPR4AcgrnWVGAAAA
    • Transformation rule

      e_set("gzip_decompress",gzip_decompress(v("content"),from_format="base64"))
    • Result

      content: H4sIAA8JXl4C/xXK0QmAMAwFwFXeBO7RMQKNREx5kAZDtle/7wbES3rDyRsnoyQmklgNo1/ztzJN08BAhjzqYGCnNCS/tPR4AcgrnWVGAAAA
      gzip_decompress: I always look forward to my holidays whether I travel or stay at home.
  • Example 2: Decompress a log field whose value is hex-encoded.

    • Raw log

      content:1f8b0800bff8856202ff0dc1dd0e43301800d047aa65156e3ff52f4a2ba17649c43255194d4a9f9e73527c64007e2e2426e81485c35628c1c42616535079bc6405e5d1e92ef009b59c906786a879efe1c50fb55d6c5de44cb717b2dae6d4f103f8feecbf4f88a2a441bae618c679575d9bc0e306907876806c000000
    • Transformation rule

      e_set("gzip_decompress", gzip_decompress(v("content"), from_format="hex"))
    • Result

      content:1f8b0800bff8856202ff0dc1dd0e43301800d047aa65156e3ff52f4a2ba17649c43255194d4a9f9e73527c64007e2e2426e81485c35628c1c42616535079bc6405e5d1e92ef009b59c906786a879efe1c50fb55d6c5de44cb717b2dae6d4f103f8feecbf4f88a2a441bae618c679575d9bc0e306907876806c000000
      gzip_decompress:H4sIAA8JXl4C/xXK0QmAMAwFwFXeBO7RMQKNREx5kAZDtle/7wbES3rDyRsnoyQmklgNo1/ztzJN08BAhjzqYGCnNCS/tPR4AcgrnWVGAAAA

zlib_compress

Compresses data and encodes the result in Base64 format.

Syntax

zlib_compress(data, compresslevel=6, to_format="base64", encoding="utf-8")

Parameters

Parameter

Type

Required

Description

data

String

Yes

The data to compress.

compresslevel

Int

No

The compression level. Set this parameter to an integer from 0 to 9, where a larger value indicates a higher compression ratio and a lower compression speed. Default value: 6. Valid values:

  • 0: no compression.

  • 1: the fastest compression speed but the lowest compression ratio.

  • 9: the slowest compression speed but the highest compression ratio. |

    |to_format |String |No |The format used to encode the compressed data. Currently, only Base64 encoding is supported. | |encoding |String |No |The encoding format of the original, uncompressed data. Default value: utf-8.

Response

Returns the encoded object.

Examples

  • Example: Compress the value of the content field and encode the result by using Base64.

    • Raw log

      content: I always look forward to my holidays whether I travel or stay at home.
    • Transformation rule

      e_set("zlib_compress", zlib_compress(v("content"), to_format="base64"))
    • Result

      content: I always look forward to my holidays whether I travel or stay at home.
      zlib_compress: eJwVytEJgDAMBcBV3gTu0TECjURMeZAGQ7ZXv+8GxEt6w8kbJ6MkJpJYDaNf87cyTdPAQIY86mBgpzQkv7T0eAGNshln

zlib_decompress

Decompresses compressed data that is Base64-encoded.

Syntax

zlib_decompress(data, from_format="base64", encoding="utf-8")

Parameters

Parameter

Type

Required

Description

data

String

Yes

The data to decompress.

from_format

String

No

The encoding format of the data to decompress. Currently, only Base64 encoding is supported.

encoding

String

No

The encoding format. Default value: utf-8.

Response

Returns the decompressed object.

Examples

  • Example: Decompress the Base64-encoded value of the content field.

    • Raw log

      content: eJwVytEJgDAMBcBV3gTu0TECjURMeZAGQ7ZXv+8GxEt6w8kbJ6MkJpJYDaNf87cyTdPAQIY86mBgpzQkv7T0eAGNshln
    • Transformation rule

      e_set("zlib_decompress", zlib_decompress(v("content"), from_format="base64"))
    • Result

      content: eJwVytEJgDAMBcBV3gTu0TECjURMeZAGQ7ZXv+8GxEt6w8kbJ6MkJpJYDaNf87cyTdPAQIY86mBgpzQkv7T0eAGNshln
      zlib_decompress: I always look forward to my holidays whether I travel or stay at home.

aes_encrypt

Encrypts data by using AES. The Advanced Encryption Standard (AES) is a common symmetric encryption algorithm that helps improve data security.

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 to encrypt.

key

String

Yes

The key used to encrypt the data.

mode

String

No

The AES encryption mode. Valid values:

  • CBC (default): Cipher Block Chaining

  • ECB: Electronic Code 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 input character format. Default value: raw. Valid values:

  • raw: byte format

  • hex: hexadecimal format

  • base64: Base64 encoding format |

    |input_encoding |String |No |The character encoding format. Required only if input_format is set to raw. Default value: utf-8. | |output_format |String |No |The output character format. Default value: hex. Valid values:

  • raw: byte format

  • hex: hexadecimal format

  • base64: Base64 encoding format |

    |iv |Bytes |No |The initialization vector (IV) for encryption. |

Response

Returns the encrypted string.

Examples

  • Example 1: Encrypt a field value and return the result in Base64 format.

    • Raw log

      "test": "aliyuntest"
    • Transformation rule

      e_set('result',aes_encrypt(v("test"), "qwertyuiopasdfgd", iv=b"xxywosjdapdiawdk", output_format="base64"))
    • Result

      "result": "gXIqu0cBBtZHQxJBK8GLeA=="
  • Example 2: Encrypt a field value by using the OFB mode.

    • Raw log

      "test": "aliyuntest"
    • Transformation rule

      e_set('result',aes_encrypt(v("test"), "qwertyuiopasdfgh", iv=b"ywisnjaduaqibdqi", mode="OFB"))
    • Result

      "result": "5cac3e9e1c42f713dc6d"

aes_decrypt

Decrypts AES-encrypted data.

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 to decrypt.

key

String

Yes

The key used to decrypt the data.

mode

String

No

The AES decryption mode. Valid values:

  • CBC (default): Cipher Block Chaining

  • ECB: Electronic Code 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 input character format. Default value: hex. Valid values:

  • raw: byte format

  • hex: hexadecimal format

  • base64: Base64 encoding format |

    |input_encoding |String |No |The character encoding format. Required only if input_format is set to raw. Default value: utf-8. | |output_format |String |No |The output character format. Default value: raw. Valid values:

  • raw: byte format

  • hex: hexadecimal format

  • base64: Base64 encoding format |

    |iv |Bytes |No |The initialization vector (IV) for decryption. | |output_encoding |String |No |The character encoding format of the output. Default value: None. |

Response

Returns the decrypted string.

Examples

  • Example 1: Decrypt a Base64-encoded field value.

    • Raw log

      "test": "gXIqu0cBBtZHQxJBK8GLeA=="
    • Transformation rule

      e_set('result', aes_decrypt(v("test"), "qwertyuiopasdfgd", iv=b"xxywosjdapdiawdk", input_format="base64"))
    • Result

      "result": "aliyuntest"
  • Example 2: Decrypt a field value by using the OFB mode.

    • Raw log

      "test": "5cac3e9e1c42f713dc6d"
    • Transformation rule

      e_set('result', aes_decrypt(v("test"), "qwertyuiopasdfgh", iv=b"ywisnjaduaqibdqi", mode="OFB"))
    • Result

      "result": "aliyuntest"

md5_encoding

Calculates the MD5 hash of data.

Syntax

md5_encoding(value, format="hex")

Parameters

Parameter

Type

Required

Description

value

String

Yes

The value to encode.

format

String

No

The encoding type. Default value: hex. Valid values: binary and hex.

Response

Returns the encoded string.

Examples

  • Example 1: Calculate the MD5 hash of a field value in the default hex format.

    • Raw log

      str : GeeksforGeeks
    • Transformation rule

      e_set("str_md5_en",md5_encoding(v("str")))
    • Result

      str : GeeksforGeeks
      str_md5_en : f1e069787ece74531d112559945c6871
  • Example 2: Calculate the MD5 hash of a field value in binary format and then encode the hash by using Base64.

    • Raw log

      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

Calculates the SHA-1 hash of data.

Syntax

sha1_encoding(value, format=None)

Parameters

Parameter

Type

Required

Description

value

String

Yes

The value to encode.

format

String

No

The encoding type. Default value: SHA1. Valid values: SHA224, SHA256, SHA384, and SHA512.

Response

Returns the encoded string.

Examples

  • Example: Calculate the SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512 hashes of the str field.

    • Raw log

      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

crc32_encoding

Calculates the CRC-32 checksum of data.

Syntax

crc32_encoding(data, input_format="raw", input_encoding="utf-8")

Parameters

Parameter

Type

Required

Description

data

String

Yes

The value for which to calculate the checksum.

input_format

String

No

The character format of the input value. Default value: raw. Valid values:

  • raw: byte format

  • hex: hexadecimal format

  • base64: Base64 encoding format |

    |input_encoding |String |No |The character encoding format. Required only if input_format is set to raw. Default value: utf-8. |

Response

Returns the CRC-32 checksum of the input data.

Examples

  • Example 1: Calculate the CRC-32 checksum of the test field.

    • Raw log

      test: aliyuntest
    • Transformation rule

      e_set("str_crc32", crc32_encoding(v("test")))
    • Result

      test:aliyuntest
      str_crc32:1434103726
  • Example 2: Concatenate the test1 and test2 fields, calculate the MD5 hash, and then calculate the CRC-32 checksum of the hash.

    • Raw log

      test1: test1
      test2: test2
    • Transformation rule

      e_set(
          "str_crc32",
          crc32_encoding(
              md5_encoding(str_join("+", v("test1"), v("test2")), format="binary")
          ),
      )
    • Result

      test1:test1
      test2:test2
      str_crc32:369733261
  • Example 3: Calculate the CRC-32 checksum of the test field, whose value is in Base64 encoding format.

    • Raw log

      test: Taloz+e+PzP3NltrEXiCig==
    • Transformation rule

      e_set("str_crc32", crc32_encoding(v("test"), input_format="base64"))
    • Result

      test:Taloz+e+PzP3NltrEXiCig==
      str_crc32:1093789404