Updated on 2024-11-13 GMT+08:00

Generating SHA256 Encoding

Function Name

$sha256(StringA)

Parameter Description

StringA: string to be encoded. The value contains a maximum of 256 bytes and supports the following special characters: !*'();:@&=+$,/?#[]-.~%<>_|{}`^.

Function Description

Performs SHA256 encoding on strings. Parameter A supports the following types:

  • Value in the format listed in Parameter Description
  • Environment parameters
  • Local parameters
  • Other built-in functions

Application Scenarios

The SHA256 encoding generation function can be used in the following scenarios for API automation cases:

  • Request URL
  • Request header
  • Request body
  • Checkpoint property
  • if condition
  • for loop interrupt condition

Example

  • Request URL

    As shown in the following figure, the value of test in the request URL is the SHA256 encoding generation function. Parameter A in the function is the string abc123.

  • Request header

    As shown in the following figure, the value of Accept-Encoding in the request header is the SHA256 encoding generation function. Parameter A in the function is the string abc123.

  • Request body

    As shown in the following figure, the request body uses the SHA256 encoding generation function. Parameter A in the function is $uuid().

  • Checkpoint property

    As shown in the following figure, the target value of the checkpoint property result is the SHA256 encoding generation function. Parameter A in the function is the local parameter test. For details about how to set local parameters, see Local Parameters.

  • if condition

    As shown in the following figure, the target value of the if condition is the SHA256 encoding generation function. Parameter A in the function is the environment variable status. For details about how to set environment parameters, see Setting Environment Parameters of an API Script.

  • for loop interrupt condition

    As shown in the following figure, the target value of the for loop interrupt condition is the SHA256 encoding generation function. Parameter A in the function is the string abc123.