Bcryptjs icon

Bcryptjs

Perform password hashing and verification using bcryptjs

Overview

This node provides various operations related to bcryptjs, a popular library for password hashing and verification. It allows you to generate salts, hash passwords, compare passwords against hashes, and extract information from existing bcrypt hashes such as the number of rounds or the salt used.

Common scenarios where this node is useful include:

  • Securely storing user passwords by hashing them before saving.
  • Verifying user login attempts by comparing entered passwords with stored hashes.
  • Inspecting bcrypt hashes to understand their parameters (e.g., rounds or salt).
  • Generating salts for custom hashing workflows.

Practical example: You can use the "Get Rounds" operation to determine how many rounds were used to create a given bcrypt hash, which helps in auditing password security settings.

Properties

Name Meaning
Hash The bcrypt hash value to analyze or compare against a password.
Options Collection of additional options:
  Output Field Name The name of the field in the output JSON where the result will be saved. Default is "result".

Output

The node outputs an array of items, each containing a json object. This object includes all original input fields plus one additional field (default named "result" or as specified in the options) holding the result of the operation.

For the "Get Rounds" operation specifically, the output field contains a number representing the cost factor (rounds) used when creating the provided bcrypt hash.

No binary data is produced by this node.

Example output JSON snippet for "Get Rounds":

{
  "result": 10
}

Dependencies

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

Troubleshooting

  • Common issues:

    • Providing an invalid or malformed bcrypt hash string may cause errors.
    • Using unsupported operations will throw an error.
    • Passing non-numeric values where numbers are expected (e.g., rounds) can cause failures.
  • Error messages:

    • "Unknown operation: <operation>": Indicates the selected operation is not supported by the node. Verify the operation parameter.
    • "Bcryptjs <operation> operation failed: <message>": General failure during bcrypt processing, often due to invalid inputs like malformed hashes or incorrect parameters.
  • Resolution tips:

    • Ensure the hash strings are valid bcrypt hashes.
    • Confirm that numeric parameters like rounds are correctly formatted numbers.
    • Use the correct operation name matching the node's options.

Links and References

Discussion