Overview
This node provides functionality to hash passwords or compare plain text passwords against existing bcrypt hashes. It is useful in scenarios where you need to securely store user passwords by hashing them before saving, or verify user login attempts by comparing entered passwords with stored hashes.
Practical examples include:
- Creating a new user account and storing the hashed password.
- Authenticating users by comparing their input password with the stored hash.
- Migrating legacy password data by re-hashing or verifying passwords.
Properties
| Name | Meaning |
|---|---|
| Operation | Choose between "Hash" (to create a bcrypt hash of a password) or "Compare" (to check if a password matches an existing hash). |
| Salt Rounds | Number of salt rounds to apply when hashing the password. Higher values increase security but also processing time. Default is 10. (Only for Hash operation) |
| Plain Text Password | The password string to be hashed or compared. |
| Hash to Compare | The existing bcrypt hash to compare the password against. (Only for Compare operation) |
Output
The node outputs JSON objects with the following structure depending on the operation:
Hash operation:
{ "hashedPassword": "<bcrypt hashed password>" }This field contains the generated bcrypt hash of the input password.
Compare operation:
{ "passwordMatches": true|false }This boolean indicates whether the provided plain text password matches the given bcrypt hash.
The output preserves any original input JSON fields alongside these new fields.
The node does not output binary data.
Dependencies
- Uses the
bcryptlibrary for hashing and comparison. - Requires an environment capable of running native Node.js modules.
- No external API keys or services are needed.
Troubleshooting
- Empty Password Error: If the password input is empty, the node throws an error "Password cannot be empty." Ensure that the password field is populated.
- Empty Hash to Compare Error: When using the compare operation, if the hash to compare is missing, the node throws "Hash to compare cannot be empty." Provide a valid bcrypt hash string.
- Performance Considerations: High salt rounds increase security but also CPU usage and execution time. Adjust salt rounds according to your performance requirements.
- Continue On Fail: If enabled, errors per item will be returned as JSON with an
errorfield instead of stopping execution.