Bcryptjs icon

Bcryptjs

Perform password hashing and verification using bcryptjs

Overview

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

Common scenarios where this node is useful include:

  • Securely storing user passwords by hashing them before saving.
  • Verifying user login attempts by comparing a plaintext password with a stored hash.
  • Extracting metadata from bcrypt hashes for auditing or migration purposes.
  • Generating salts for custom hashing workflows.

Practical example: You can use this node to hash a new user's password before saving it to your database, then later verify login attempts by comparing the entered password with the stored hash.

Properties

Name Meaning
Hash The bcrypt hash value to compare against the password or to extract data from (used in "compare", "getRounds", "getSalt" operations).
Options Collection of additional options:
- Output Field Name: The name of the field where the result will be saved in the output JSON. Default is "result".

Note: The full node supports multiple operations, but here only the "Get Salt" operation is relevant. For "Get Salt", the key input property is:

  • Hash: The bcrypt hash string from which the salt portion will be extracted.

Output

The node outputs an array of items, each containing a json object. The result of the operation is saved under a field specified by the "Output Field Name" option (default "result").

For the "Get Salt" operation, the output JSON will contain the extracted salt string from the provided bcrypt hash, e.g.:

{
  "result": "$2b$10$EixZaYVK1fsbw1ZfbX3OXe"
}

No binary data is produced by this node.

Dependencies

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

Troubleshooting

  • Error: Unknown operation — This occurs if an unsupported operation is selected. Ensure the operation parameter is set correctly.
  • Bcryptjs getSalt operation failed: [error message] — Usually indicates the provided hash is invalid or malformed. Verify that the hash string is a valid bcrypt hash.
  • If the output field name is set to an empty string or invalid value, the result may not appear as expected. Use a valid string for the output field name.
  • Make sure the input hash corresponds to a bcrypt hash; other hash formats are not supported.

Links and References

Discussion