Overview
This node provides password hashing and verification functionality using the bcryptjs library. It supports generating salts, hashing passwords with salts or rounds, comparing passwords against hashes, extracting salt or rounds from a hash, and testing if a password will be truncated by bcrypt.
Common scenarios include:
- Securely storing user passwords by hashing them before saving to a database.
- Verifying user login attempts by comparing entered passwords with stored hashes.
- Generating salts for custom hashing workflows.
- Inspecting existing bcrypt hashes to retrieve metadata like salt or number of rounds.
Practical examples:
- Hash a new user's password before saving it.
- Compare a login password with the stored hash to authenticate.
- Generate a salt with a specified cost factor for advanced use cases.
- Extract the salt from a stored hash for analysis or migration.
Properties
| Name | Meaning |
|---|---|
| Operation | The action to perform: "Compare Password", "Generate Salt", "Get Rounds", "Get Salt", "Hash Password", or "Test Truncation". |
| Rounds | Number of processing rounds (cost factor) used when generating salt or hashing (default 10). |
| Minor Version | Minor version of bcrypt to use when generating salt ("a" or "b"). |
| Password | The password string to hash, compare, or test truncation on. |
| Salt or Rounds | Salt value or number of rounds to use for hashing. |
| Hash | The bcrypt hash string to compare against or extract information from. |
| Options | Collection of additional options: - Output Field Name: field name where result is saved (default "result"). |
Output
The node outputs an array of items, each containing a json object that includes all original input fields plus one additional field holding the operation result. The name of this result field defaults to "result" but can be customized via the "Output Field Name" option.
Depending on the operation, the output field contains:
- For Generate Salt: a string representing the generated salt.
- For Hash Password: a string representing the hashed password.
- For Compare Password: a boolean indicating if the password matches the hash.
- For Get Rounds: a number indicating the cost factor used in the hash.
- For Get Salt: a string representing the salt extracted from the hash.
- For Test Truncation: a boolean indicating if the password would be truncated by bcrypt.
No binary data is output by this node.
Dependencies
- Requires the
bcryptjsnpm package bundled within the node. - No external API keys or services are needed.
- No special environment variables or n8n credentials required.
Troubleshooting
Common issues:
- Providing an invalid salt or rounds value when hashing may cause errors.
- Comparing a password with an improperly formatted hash will fail.
- Using unsupported operations will throw an error.
Error messages:
"Unknown operation: <operation>": Indicates an unsupported operation was selected; verify the operation parameter."Bcryptjs <operation> operation failed: <message>": General failure during bcrypt processing; check input values for correctness.
Resolutions:
- Ensure rounds is a valid integer (usually between 4 and 31).
- Provide correctly formatted bcrypt hashes for comparison or extraction.
- Use supported operations only as listed in the properties.