Hash

The Hash function computes one or more hashes using a specified algorithm.

Parameters

Name Description Default value Accepted values
$data Data to be hashed (one or more strings) undefined string or string[] (all array items must be strings)
algorithm The hashing algorithm to use (e.g., 'sha256', 'md5'). sha256 A string representing a valid hashing algorithm supported by the Node.js crypto module.

Output

The Hash function executes a trigger of type success with hashed values in the data property.

  • The data output is always an array of strings.
  • If the input is a single string, the output contains one hash item.
  • If the input is an array of strings, the output contains one hash per input item in the same order.

If an error occurs during hashing (for example, an unsupported algorithm is provided or the input data is not a string/string-array), it executes an error trigger.

Example

To compute the SHA256 hash of a single string:

{
  "$function": "Hash",
  "$data": "Hello World",
  "algorithm": "sha256"
}

The success trigger returns:

{
  "type": "success",
  "data": [
    "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b27796d9ad3d6e"
  ]
}

To compute hashes for multiple strings:

{
  "$function": "Hash",
  "$data": ["Hello", "World"],
  "algorithm": "sha256"
}

The success trigger returns:

{
  "type": "success",
  "data": [
    "185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969",
    "78ae647dc5544d227130a0682a51e30bc7777fbb6d8a8f17007463a3ecd1d524"
  ]
}