Actions2
Overview
This node provides functionality to hash and verify passwords using the bcrypt algorithm. It supports two main operations:
- Hash Password: Generates a secure bcrypt hash from a given plaintext password. This is useful for storing passwords securely in databases.
- Verify Password: Compares a plaintext password against an existing bcrypt hash to check if they match. This is commonly used during user authentication.
Practical examples include:
- Creating hashed passwords before saving user credentials.
- Validating user login attempts by verifying entered passwords against stored hashes.
Properties
Name | Meaning |
---|---|
Operation | Choose between "Hash Password" (generate a bcrypt hash) or "Verify Password" (compare a password with a hash). |
Password | The plaintext password to hash or verify. |
Hash | The existing bcrypt hash to compare against (required only for verification). |
Salt Rounds | Number of salt rounds to use when hashing the password; controls hashing complexity (only for hashing). Values range from 1 to 20, default is 10. |
Output
For Hash Password operation, the output JSON contains:
{ "hash": "<bcrypt hashed password string>" }
This is the generated bcrypt hash of the input password.
For Verify Password operation, the output JSON contains:
{ "match": true|false }
A boolean indicating whether the provided password matches the given bcrypt hash.
The node does not output binary data.
Dependencies
- Uses the
bcryptjs
library internally to perform hashing and verification. - Requires no additional external services or API keys.
- No special environment variables or n8n credential configurations are needed.
Troubleshooting
Common issues:
- Providing an empty password or hash may cause errors or unexpected results.
- Using an invalid bcrypt hash format for verification will likely throw an error.
- Setting salt rounds outside the allowed range (1-20) is prevented by the UI but could cause issues if bypassed programmatically.
Error messages:
- Errors related to invalid hash formats or failed comparisons will be thrown by the underlying bcryptjs library.
- If "continue on fail" is enabled, errors will be returned as part of the output JSON under an
error
field with the message.
To resolve errors:
- Ensure valid, non-empty inputs for password and hash fields.
- Use appropriate salt rounds within the specified range.
- Verify that the hash string is a valid bcrypt hash when performing verification.