HMAC-SHA256

Description

The zoho.encryption.hmacsha256 task returns the hash corresponding to the given text generated using the HMAC-SHA256 algorithm.

Syntax

<response> = zoho.encryption.hmacsha256(<key>, <data>, <output_type>);

where:

ParamsData typeDescription
<response>TEXTThe hash generated using HMAC-SHA256 algorithm.
<key>TEXTThe secret key with which the hash needs to be generated.
<data>TEXTThe source text whose corresponding hash needs to be computed.

<output_type>

(Optional)

TEXT

The type in which the generated hash needs to be represented. By default, the output type is base64.

Allowed values:

  • base64 - returns the hash in base 64 format
  • hex - returns the hash in hexadecimal format
  • binary - returns the hash in binary format

Example 1: Generate hash in base64 format using the HMAC-SHA256 algorithm

The following script returns the hash generated using the HMAC-SHA256 algorithm for the text - {Order ID: 0932, Currency: USD,  Amount: 2500} with the key - sk_5Ow7B_4eC39H in base64 format:

response = zoho.encryption.hmacsha256("sk_5Ow7B_4eC39H","{Order ID: 0932, Currency: USD, Amount: 2500}");

where:

response
The TEXT that represents the hash value returned by this task. Here, the hash returned is E3IZY+esQ59aLmPCYYVjk2R/P1G0k77r9ZGa9Lw94Zw=
"sk_5Ow7B_4eC39H"
The TEXT that represents the secret key with which the hash is generated.
"{Order ID: 0932, Currency: USD, Amount: 2500}"
The TEXT that represents the source text whose corresponding hash needs to be computed.

Example 2: Generate hash in hexadecimal format using the HMAC-SHA256 algorithm

The following script returns the hash generated using the HMAC-SHA256 algorithm for the text - {Order ID: 0932, Currency: USD, Amount: 2500} with the key - sk_5Ow7B_4eC39H hash in hexadecimal format:

response = zoho.encryption.hmacsha256("sk_5Ow7B_4eC39H","{Order ID: 0932, Currency: USD, Amount: 2500}", "hex");

where:

response    
The TEXT that represents the hash value returned by this task. Here, the hash returned is 13721963e7ac439f5a2e63c261856393647f3f51b493beebf5919af4bc3de19c.
"hex"
The TEXT that represents the output type of the hash. Here, the hash is represented in hexadecimal format.

Related Links