Hash File icon

Hash File

Calculate the hash of a file

Overview

This node calculates a cryptographic hash of a file provided as binary data. It supports multiple hashing algorithms, including SHA-256, MD5, SHA-1, SHA-512, SHA-384, RIPEMD160, and WHIRLPOOL. 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-related workflows. For example, you might use it to generate a checksum for uploaded files to ensure they have not been tampered with or corrupted during transfer.

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 data 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: An object that includes all original JSON data merged with a new field (named as per 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 for hashing.
  • No external API keys or services are required.
  • No special n8n environment variables or credentials needed.

Troubleshooting

  • Missing or incorrect binary field: If the specified input binary field does not exist or is empty, the node will fail to retrieve the binary data buffer. Ensure the binary field name matches exactly the field in the incoming data.
  • Unsupported hash algorithm: The node restricts choices to supported algorithms. Selecting an unsupported algorithm manually (e.g., via custom modifications) may 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