Bcryptjs icon

Bcryptjs

Perform password hashing and verification using bcryptjs

Overview

This node provides various bcryptjs operations for password hashing and verification. It is useful in scenarios where secure password management is required, such as user authentication systems or data protection workflows. The node supports generating salts, hashing passwords, comparing passwords against hashes, extracting salt or rounds from hashes, and testing password truncation.

Practical examples:

  • Generating a salt to use for hashing passwords securely.
  • Hashing a user's password before storing it in a database.
  • Comparing a login password with a stored hash to verify credentials.
  • Extracting the number of rounds used in a hash for auditing or validation purposes.

Properties

Name Meaning
Rounds The cost factor for processing the data; higher values increase security but slow down processing. Default is 10. Applicable for "Generate Salt" and "Hash Password" operations.
Minor Version The minor version of bcrypt to use when generating salt. Options: "A", "B". Only for "Generate Salt" operation.
Options Collection of additional options:
- Output Field Name: The name of the field where the result will be saved (default: "result").

Output

The node outputs JSON data containing all original input fields plus an additional field holding the result of the selected operation. The name of this output field can be customized via the "Output Field Name" property (default is result).

The content of the output field depends on the operation:

  • For "Generate Salt": a generated salt string.
  • For "Hash Password": the hashed password string.
  • For "Compare Password": a boolean indicating if the password matches the hash.
  • For "Get Rounds": a number representing the rounds used in the hash.
  • For "Get Salt": the salt extracted from the hash.
  • For "Test Truncation": a boolean indicating if the password will be truncated.

No binary data is produced by this node.

Dependencies

  • Requires the bcryptjs library bundled within the node.
  • No external API keys or services are needed.
  • No special environment variables or n8n configurations are required beyond standard node setup.

Troubleshooting

  • Common issues:

    • Providing invalid or malformed hash strings may cause errors during comparison or extraction operations.
    • Using non-numeric or out-of-range values for rounds can lead to unexpected behavior.
    • Forgetting to set the correct operation or mismatching properties for the chosen operation.
  • Error messages:

    • "Unknown operation: <operation>": Indicates an unsupported operation was selected. Verify the operation name.
    • "Bcryptjs <operation> operation failed: <message>": General failure message wrapping underlying bcryptjs errors. Check input parameters for correctness.

To resolve errors, ensure that inputs conform to expected formats and that the operation-specific properties are correctly configured.

Links and References

Discussion