Skip to main content

$hash

The $hash operator computes a hash of the input using the specified algorithm.

Input

  • An array containing exactly two values: the input value to hash and the hash algorithm to use (“md5”, “sha1”, or “sha256”)

Output

  • A string representation of the computed hash

Examples

Compute MD5 Hash

{
  "$hash": [
    "hello world",
    "md5"
  ]
}
Result: "5d41402abc4b2a76b9719d911017c592"

Compute SHA256 Hash

{
  "$hash": [
    "hello world",
    "sha256"
  ]
}
Result: "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e"

From Fields

{
  "$hash": [
    {
      "$input": "data"
    },
    {
      "$input": "algorithm"
    }
  ]
}
Result: The hash of the data field using the algorithm specified in the algorithm field