Overview
This node provides functionality to work with bcrypt password hashing and verification using the bcryptjs library. It supports operations such as hashing a password, generating a salt, comparing a password against a hash, extracting salt or rounds from a hash, and testing if a password will be truncated.
A common use case is securely storing user passwords by hashing them before saving to a database, and later verifying login attempts by comparing entered passwords with stored hashes. For example, when a user registers, you can hash their password; when they log in, you compare the entered password with the stored hash.
The "Compare Password" operation specifically allows asynchronously checking if a given plaintext password matches a provided bcrypt hash, returning a boolean result.
Properties
| Name | Meaning |
|---|---|
| Password | The plaintext password to process (hash or compare). |
| Hash | The bcrypt hash value to compare against the password. |
| Options | Collection of additional options: |
| Output Field Name | The name of the field where the comparison result (true/false) will be saved. Defaults to "result". |
Output
The node outputs an array of items, each containing a json object. For the "Compare Password" operation, the output JSON includes a field (default "result", configurable via options) set to a boolean indicating whether the password matches the hash (true) or not (false).
Example output JSON for one item:
{
"result": true
}
No binary data is produced by this node.
Dependencies
- Requires the
bcryptjsnpm package bundled with the node. - No external API keys or services are needed.
- Runs entirely locally within n8n.
Troubleshooting
Common issues:
- Providing an invalid or malformed bcrypt hash string may cause errors.
- Comparing a password without providing both required inputs (
passwordandhash) will fail. - Using unsupported operations will throw an error.
Error messages:
Bcryptjs compare operation failed: <message>indicates failure during password comparison, often due to invalid input parameters.Unknown operation: <operation>means the selected operation is not implemented.
Resolutions:
- Ensure the hash string is a valid bcrypt hash.
- Provide all required parameters for the chosen operation.
- Select a supported operation from the dropdown.