本文档主要介绍编码解码函数的语法规则,包括参数解释、函数示例等。

函数列表

类型 函数 说明
URL类型 url_encoding 对URL类型数据进行URL编码。
url_decoding 对URL类型数据进行URL解码。
Base64类型 base64_encoding 对数据进行Base64编码。
base64_decoding 对数据进行Base64解码。
HTML类型 html_encoding 对数据进行HTML编码。
html_decoding 对数据进行HTML解码。
MD5类型 md5_encoding 对数据进行MD5编码。
SHA1类型 sha1_encoding 对数据进行SHA1编码。
IP类型 ip2long 将IP地址转换成长整型数据。
long2ip 将长整型数据转换成IP地址。

url_encoding

使用url_encoding函数对URL类型数据进行URL编码。

  • 函数格式
    url_encoding(值)
  • 参数说明
    名称 类型 是否必填 说明
    String 填入需要被编码的值。
  • 返回结果

    返回对值进行URL编码后的字符串。

  • 函数示例
    • 原始日志
      content : https://www.urlencoder.org/hello/asdah
    • 加工规则
      e_set("url",url_encoding(v("content")))
    • 加工结果
      content : https://www.urlencoder.org/hello/asdah
      url: https%3A%2F%2Fwww.urlencoder.org%2FHello%2Fasdah

url_decoding

使用url_decoding函数对URL类型数据进行URL解码。

  • 函数格式
    url_decoding(值)
  • 参数说明
    名称 类型 是否必填 说明
    String 填入需要被解码的值。
  • 返回结果

    返回对值进行URL解码后的字符串。

  • 函数示例
    • 原始日志
      content : https%3A%2F%2Fwww.urlencoder.org%2FHello%2Fasdah
    • 加工规则
      e_set("URL",url_decoding(v("content")))
    • 加工结果
      content : https%3A%2F%2Fwww.urlencoder.org%2FHello%2Fasdah
      URL : https://www.urlencoder.org/hello/asdah

base64_encoding

使用base64_encoding函数对数据进行Base64编码。

  • 函数格式
    base64_encoding(值,format=None)
  • 参数说明
    名称 类型 是否必填 说明
    String 填入需要被编码的值。
    format String Base64编码协议。默认为format=RFC3548,还可以配置为format=RFC4648。
  • 返回结果

    返回对值进行Base64编码后的字符串。

  • 函数示例
    • 原始日志
      str_en : data to be encoded
    • 加工规则
      e_set("str_base64",base64_encoding(v("str_en")))
    • 加工结果
      str_en : data to be encoded
      str_base64 : ZGF0YSB0byBiZSBlbmNvZGVk

base64_decoding

使用base64_decoding函数对数据进行Base64解码。

  • 函数格式
    base64_decoding(值,format=None)
  • 参数说明
    名称 类型 是否必填 说明
    String 填入需要被解码的值。
    format String Base64解码协议。默认为format=RFC3548,还可以配置为format=RFC4648。
    说明 RFC4648的Base64解码协议使用等号(=)将被解码的值填充到4字节的倍数。
  • 返回结果

    返回对值进行Base64解码后的字符串。

  • 函数示例
    • 原始日志
      str_de: ZGF0YSB0byBiZSBlbmNvZGVk
    • 加工规则
      e_set("str_de_base64",base64_decoding(v("str_de")))
    • 加工结果
      str_de: ZGF0YSB0byBiZSBlbmNvZGVk
      str_de_base64: data to be encoded

html_encoding

使用html_encoding函数对数据进行HTML编码。

  • 函数格式
    html_encoding(值)
  • 参数说明
    名称 类型 是否必填 说明
    String 填入需要被编码的值。
  • 返回结果

    返回对值进行HTML编码后字符串。

  • 函数示例
    • 原始日志
      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" />
    • 加工规则
      e_set("str_html_en",html_encoding(v("str")))
    • 加工结果
      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

使用html_decoding函数对数据进行HTML解码。

  • 函数格式
    html_decoding(值)
  • 参数说明
    名称 类型 是否必填 说明
    String 填入需要被解码的值。
  • 返回结果

    返回对值进行HTML解码后字符串。

  • 函数示例
    • 原始日志
      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;
    • 加工规则
      e_set("str_html_de",html_decoding(v("str")))
    • 加工结果
      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

使用md5_encoding函数对数据进行MD5编码。

  • 函数格式
    md5_encoding(值,format="hex")
  • 参数说明
    名称 类型 是否必填 说明
    String 填入需要被编码的值。
    编码形式 String 默认值为hex,可选值:binary、hex。
  • 返回结果

    返回对值进行MD5编码后的字符串。

  • 函数示例
    • 示例1
      • 原始日志
        str : GeeksforGeeks
      • 加工规则
        e_set("str_md5_en",md5_encoding(v("str")))
      • 加工结果
        str : GeeksforGeeks
        str_md5_en : f1e069787ece74531d112559945c6871
    • 示例2
      • 原始日志
        str : GeeksforGeeks
      • 加工规则
        e_set("str_md5_en",base64_encoding(md5_encoding(v("str"), format="binary")))
      • 加工结果
        str : GeeksforGeeks
        str_md5_en : 8eBpeH7OdFMdESVZlFxocQ==

sha1_encoding

使用sha1_encoding函数对数据进行SHA-1编码。

  • 函数格式
    sha1_encoding(值,format=None)
  • 参数说明
    名称 类型 是否必填 说明
    String 填入需要被编码的值。
    format String 编码类型,默认为SHA1类型,可选SHA256、SHA384、SHA224、SHA512类型。
  • 返回结果

    返回对值进行SHA1编码后的字符串。

  • 函数示例
    • 原始日志
      str : GeeksforGeeks
    • 加工规则
      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'))
    • 加工结果
      str : GeeksforGeeks
      str_sha1 : 4175a37afd561152fb60c305d4fa6026b7e79856
      str_sha512 : 0d8fb9370a5bf7b892be4865cdf8b658a82209624e33ed71cae353b0df254a75db63d1baa35ad99f26f1b399c31f3c666a7fc67ecef3bdcdb7d60e8ada90b722
      str_sha224 : 173994f309f727ca939bb185086cd7b36e66141c9e52ba0bdcfd145d
      str_sha384 : d1e67b8819b009ec7929933b6fc1928dd64b5df31bcde6381b9d3f90488d253240490460c0a5a1a873da8236c12ef9b3
      str_sha256 : f6071725e7ddeb434fb6b32b8ec4a2b14dd7db0d785347b2fb48f9975126178f

ip2long

使用ip2long函数将IP地址转换成长整型数据。

  • 函数格式
    ip2long(值,default=0)
  • 参数说明
    名称 类型 是否必填 说明
    String 填入需要被转换的值。
    default String 某个不合法的IP地址被转换成的值。支持自定义,例如:0。
  • 返回结果

    返回有效IP转换成功后的长整型数据。

  • 函数示例
    • 示例1:默认情况
      • 原始日志
        ip: 10.0.0.0
      • 加工规则
        e_set("long_ip",ip2long(v("ip")))
      • 加工结果
        ip: 10.0.0.0
        long_ip: 167772160
    • 示例2:非法IP情况
      • 原始日志
        ip: 333.1.1.1
      • 加工规则
        e_set("long_ip",ip2long(v("ip"), "ignore"))
      • 加工结果
        ip: 333.1.1.1
        long_ip: 0

long2ip

使用long2ip函数将长整型数据转换成IP地址。

  • 函数格式
    long2ip(值,default="")
  • 参数说明
    名称 类型 是否必填 说明
    String 填入需要被转换的值。
    default String 表示将不合法的长整型数据转成空字符串,支持自定义。
  • 返回结果

    返回有效长整型转换成功后的IP地址。

  • 函数示例
    • 示例1:默认情况
      • 原始日志
        long: 167772160
      • 加工规则
        e_set("ip",long2ip(v("long")))
      • 加工结果
        long: 167772160
        ip: 10.0.0.0
    • 示例2:非法IP情况
      • 原始日志
        long: 4294967296
      • 加工规则
        e_set("ip",long2ip(v("long")))
      • 加工结果
        long: 4294967296
        ip: 
    • 示例3:非法IP时自定义的出错处理。
      • 原始日志
        long: 4294967296
      • 加工规则
        e_set("ip",long2ip(v("long"),default="xxx"))
      • 加工结果
        long: 4294967296
        ip: xxx