Crypto Tools

Universal crypto operations: encryption, decryption, hashing, and more

Overview

The node provides a set of universal cryptographic operations including encryption, decryption, hashing, HMAC generation, key derivation, and encoding/decoding in Base64 or Hex formats. Specifically for the HMAC operation, it generates a Hash-based Message Authentication Code (HMAC) signature using a specified hash algorithm and a secret key.

This node is beneficial when you need to:

  • Verify data integrity and authenticity by generating HMAC signatures.
  • Securely sign messages or tokens in workflows.
  • Integrate cryptographic verification steps without external tools.

Example use case:
You have an API that requires requests to be signed with an HMAC signature using SHA256 and a secret key. This node can generate the required HMAC signature from your input data, which you then include in the API request headers.

Properties

Name Meaning
Hash Algorithm The hash function used to generate the HMAC. Options: BLAKE2b512, MD5, SHA1, SHA256, SHA3-256, SHA3-512, SHA512
Key The secret key/password used for generating the HMAC signature.
Input Data The string data to be processed and signed with HMAC.
Input Format Format of the input data. Options: UTF-8 String, Base64, Hex
Output Format Format of the output HMAC signature. Options: Base64, Hex, UTF-8 String, JSON (auto-parsed)

Output

The node outputs a JSON object with the following fields:

  • operation: The performed operation name, here always "hmac".
  • result: The generated HMAC signature in the selected output format.
  • success: Boolean indicating if the operation succeeded (true).
  • inputLength: Length of the input data string.

If the operation fails and "Continue On Fail" is enabled, the output will contain:

  • error: Error message describing the failure.
  • success: false

No binary data output is produced by the HMAC operation; all results are encoded as strings according to the chosen output format.

Dependencies

  • Uses Node.js built-in crypto module for cryptographic functions.
  • No external services or APIs are required.
  • Requires the user to provide a valid secret key for HMAC generation.
  • No special environment variables or n8n credentials are needed beyond the key input property.

Troubleshooting

  • Common issues:

    • Providing an empty or invalid key will cause errors.
    • Using unsupported hash algorithms or input/output formats may throw errors.
    • Incorrect input format setting (e.g., specifying Base64 but providing plain text) can lead to unexpected results or failures.
  • Error messages:

    • "HMAC failed: <message>" indicates an error during HMAC generation, often due to invalid parameters.
    • "Unknown input format: <format>" means the input format parameter is not recognized.
    • "Unknown hash algorithm: <algorithm>" if an unsupported hash algorithm is specified.
  • Resolution tips:

    • Ensure the key is correctly provided and matches expected format.
    • Double-check input and output format settings correspond to actual data encoding.
    • Use one of the supported hash algorithms listed in the properties.

Links and References

Discussion