Overview
This node provides functionality to perform password hashing and verification using the bcryptjs library. It supports operations such as generating a salt, hashing a password, comparing a password against a hash, extracting information from a hash (like rounds and salt), and testing if a password will be truncated by bcrypt.
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 asynchronous comparison of a plaintext password against an existing bcrypt hash, returning whether they match.
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 result (true/false) will be saved in the output JSON. Defaults to "result". |
Output
The node outputs an array of items, each containing a json object that includes all original input fields plus one additional field (default named "result" or as specified in options).
For the "Compare Password" operation, this added field contains a boolean indicating whether the provided password matches the given hash (true if matched, false otherwise).
No binary data output is produced by this node.
Example output JSON for one item:
{
"json": {
"password": "userInputPassword",
"hash": "$2a$10$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36bQ6v5r7q0h8f9jK1lF4G6",
"result": true
}
}
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 will cause errors.
- Comparing passwords without providing both password and hash parameters will fail.
- Using unsupported operations will throw an error.
Error messages:
"Bcryptjs compare operation failed: <error message>"indicates failure during password comparison, often due to invalid inputs."Unknown operation: <operation>"means the selected operation is not implemented.
Resolutions:
- Ensure the hash string is a valid bcrypt hash.
- Provide all required parameters according to the operation.
- Select only supported operations listed in the node's properties.