Hash File icon

Hash File

Calculate the hash of a file

Overview

This node calculates the cryptographic hash of a binary file provided as input. It supports multiple hashing algorithms such as SHA-1, SHA-256, MD5, and others. The node reads the binary data from a specified input field, computes the hash using the selected algorithm, and outputs the hash value in a JSON field.

Common scenarios for this node include verifying file integrity, generating unique identifiers for files, or preparing data for security-related workflows. For example, you might use it to generate a SHA-1 hash of an uploaded document to check if it has been altered or to create a fingerprint for deduplication purposes.

Properties

Name Meaning
Hash Algorithm The cryptographic hash function to apply. Options: SHA-256, MD5, SHA-1, SHA-512, SHA-384, RIPEMD160, WHIRLPOOL
Input Binary Field The name of the input binary field containing the file to be hashed (default: "data").
Output Hash Field The name of the JSON field where the resulting hash string will be stored (default: "hash").

Output

The node outputs an array of items where each item contains:

  • json: The original JSON data merged with a new field (name defined by the "Output Hash Field" property) containing the computed hash string in hexadecimal format.
  • binary: The original binary data is passed through unchanged.

No binary output is generated by this node; it only adds the hash string to the JSON part of the output.

Dependencies

  • Uses Node.js built-in crypto module to perform hashing operations.
  • Requires the input data to contain binary data accessible via the specified input binary field.
  • No external API keys or services are needed.

Troubleshooting

  • Missing or incorrect binary field: If the specified input binary field does not exist or contains no data, the node will fail to compute the hash. Ensure the binary field name matches exactly the field in the incoming data.
  • Unsupported hash algorithm: The node only supports the listed algorithms. Selecting an unsupported algorithm will cause an error.
  • Empty input data: If no input items are received, the node will output an empty array.
  • Large files: Processing very large binary files may impact performance or memory usage.

Links and References

Discussion