Overview
This node provides various operations related to bcrypt password hashing and verification using the bcryptjs library. It supports generating salts, hashing passwords, comparing passwords against hashes, extracting salt or rounds from a hash, and testing password truncation behavior.
Common scenarios where this node is useful include:
- Securely hashing user passwords before storing them in a database.
- Verifying user login attempts by comparing plaintext passwords with stored bcrypt hashes.
- Extracting metadata (like salt or number of rounds) from existing bcrypt hashes for auditing or migration purposes.
- Generating new salt values for custom hashing workflows.
Practical examples:
- When a new user registers, use the "Hash Password" operation to create a secure hash of their password.
- During login, use the "Compare Password" operation to verify if the entered password matches the stored hash.
- Use "Get Rounds" to check the cost factor used in an existing hash to ensure it meets security policies.
Properties
| Name | Meaning |
|---|---|
| Hash | The bcrypt hash value to compare against the password or extract information from. |
| Options | Collection of additional options: |
| Output Field Name | The name of the field in the output JSON where the result will be saved. Default is "result". |
Note: The "Hash" property is shown only for operations "compare", "getRounds", and "getSalt".
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 result of the selected operation.
- The name of this result field defaults to
"result"but can be customized via the "Output Field Name" option. - The content of the result depends on the operation:
- For "getRounds": a number representing the cost factor used in the hash.
- For "getSalt": a string containing the extracted salt portion of the hash.
- For "compare": a boolean indicating whether the password matches the hash.
- For "genSalt": a generated salt string.
- For "hash": the resulting bcrypt hash string.
- For "truncates": a boolean indicating if the password would be truncated.
The node does not output binary data.
Dependencies
- Requires the
bcryptjslibrary bundled within the node. - No external API keys or services are needed.
- No special environment variables or n8n credentials are required.
Troubleshooting
Common issues:
- Providing an invalid or malformed bcrypt hash string may cause errors when extracting rounds or salt.
- Using non-numeric or out-of-range values for rounds during salt generation or hashing can lead to failures.
- Forgetting to provide the required "Hash" or "Password" inputs depending on the operation will cause errors.
Error messages:
Bcryptjs <operation> operation failed: <message>indicates the specific bcryptjs function threw an error. Check the input parameters for correctness.Unknown operation: <operation>means the selected operation is not supported by the node. Verify the operation parameter.
Resolution tips:
- Ensure the hash strings conform to bcrypt format.
- Validate numeric inputs like rounds before running the node.
- Use the "Output Field Name" option to avoid overwriting important data fields.