Skip to main content

hash

Generate cryptographic hashes and HMAC signatures from message payloads.

Overview

The hash node generates cryptographic hashes and HMAC signatures from message payloads. Essential for data integrity verification, webhook signature validation, password hashing, deduplication by content fingerprint, and secure API authentication.

SHA256
Secure Hash
HMAC
Signatures
MD5
Fingerprint
Base64
Encoding

Properties

Property Type Default Description
algorithm string "SHA256" MD5, SHA1, SHA256, SHA512, HMAC
encoding string "hex" hex, base64
key string "" Secret key for HMAC signatures
property string "payload" Message property to hash
output string "payload" Property to store the resulting hash

Algorithms

MD5 / SHA1

Fast checksums, not for security

MD5:  32 hex characters
SHA1: 40 hex characters

Best for: deduplication,
file integrity checks

SHA256 / SHA512

Cryptographically secure hashing

SHA256: 64 hex characters
SHA512: 128 hex characters

Best for: data integrity,
secure fingerprinting

HMAC

Keyed-hash authentication code

Requires a secret key.
Uses SHA256 internally.

Best for: webhook validation,
API authentication

Example: SHA256 Data Integrity Verification

Hash sensor payloads to detect tampering or corruption in transit.

// Hash node configuration
{
  "algorithm": "SHA256",
  "encoding": "hex",
  "property": "payload",
  "output": "payload.hash"
}

// Input message:
{
  "payload": "temperature=24.5&humidity=62&sensor=BME280"
}

// Output message:
{
  "payload": {
    "data": "temperature=24.5&humidity=62&sensor=BME280",
    "hash": "a3f2b8c1e9d04567..."
  }
}

// Receiver can re-hash and compare to verify data integrity

Example: HMAC Webhook Signature Validation

Validate incoming webhook signatures from services like GitHub or Stripe.

// Hash node configuration
{
  "algorithm": "HMAC",
  "encoding": "hex",
  "key": "whsec_your_webhook_secret_key",
  "property": "payload"
}

// Flow: http-in → hash → switch → process
//
// 1. HTTP request arrives with:
//    Header: X-Signature: sha256=a1b2c3d4e5...
//    Body: {"event": "sensor.alert", "data": {...}}
//
// 2. Hash node computes HMAC of body
//    Result: "a1b2c3d4e5..."
//
// 3. Switch node compares:
//    msg.payload === msg.req.headers["x-signature"]
//    Match → process (trusted)
//    No match → reject (tampered)

Example: Content Deduplication

Use MD5 fingerprints to detect and drop duplicate messages.

// Hash node configuration
{
  "algorithm": "MD5",
  "encoding": "hex",
  "property": "payload",
  "output": "fingerprint"
}

// Flow: mqtt-in → hash → function (dedup) → process
//
// Function node checks against seen hashes:
var seen = flow.get("seen_hashes") || {};
if (seen[msg.fingerprint]) {
    return null;  // Drop duplicate
}
seen[msg.fingerprint] = Date.now();
flow.set("seen_hashes", seen);
return msg;

Common Use Cases

Webhook Verification

Validate HMAC signatures from GitHub, Stripe, Slack

Data Integrity

Detect corruption or tampering in sensor data

Content Deduplication

Fingerprint messages to filter duplicates

API Authentication

Sign outgoing requests with HMAC tokens

Related Nodes