Hash File icon

Hash File

Calculate the hash of a file

Overview

This node calculates the cryptographic hash of a file provided as binary data. It supports multiple hashing algorithms including MD5, SHA-256, SHA-1, and others. The node reads the binary content 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 hashes for security checks. For example, you might use it to generate an MD5 checksum of uploaded files to detect duplicates or ensure files have not been tampered with during transfer.

Properties

Name Meaning
Hash Algorithm The cryptographic hash algorithm to use. 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 whose hash will be calculated. Default is "data".
Output Hash Field The name of the JSON field where the resulting hash string will be stored. Default is "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 passed through unchanged.

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

Dependencies

  • Uses Node.js built-in crypto module to perform hashing.
  • 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 errors.
  • Large files: Processing very large binary files may impact performance or memory usage.
  • Error messages typically relate to inability to read binary data or invalid parameters. Verify input data and property settings.

Links and References

Discussion