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, extract salt or rounds from existing hashes, and test if a password will be truncated by bcrypt.

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.
  • Extracting metadata like salt or number of rounds from existing bcrypt hashes for auditing or migration purposes.
  • Generating new salt values for creating hashes with specific cost factors.

Practical example: When building a user authentication workflow, you can use the "Hash Password" operation to create a secure hash of a user's password before saving it to your database. Later, during login, use the "Compare Password" operation to verify the entered password matches the stored hash.

Properties

Name Meaning
Hash The hash value to compare against the password (used in Compare Password, Get Rounds, Get Salt operations).
Options Collection of additional options:
- Output Field Name: Field name where the result will be saved (default: "result").

Note: The "Hash" property is shown only for operations "compare", "getRounds", and "getSalt".

Output

The node outputs an array of items, each containing a json object. The result of the selected operation is saved under the field name specified in the "Options" → "Output Field Name" property (default is "result").

The content of the output field depends on the operation:

  • Get Salt: Outputs the extracted salt string portion from the provided bcrypt hash.
  • Other operations (not requested here) output corresponding results such as boolean comparison results, generated salts, hashed passwords, etc.

No binary data output 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 required beyond standard node setup.

Troubleshooting

  • Error: Unknown operation
    Occurs if an unsupported operation name is provided. Ensure the operation parameter is one of the supported options.

  • Bcryptjs operation failed: [error message]
    Indicates an error during bcrypt processing, e.g., invalid hash format or parameters. Verify that the input hash and other parameters are correctly formatted.

  • Invalid hash or password inputs
    Make sure the hash strings are valid bcrypt hashes and passwords are non-empty strings when required.

Links and References

Discussion