Password Hash icon

Password Hash

Hash and verify passwords using bcryptjs

Overview

This node provides functionality to hash passwords and verify passwords against existing bcrypt hashes using the bcryptjs library. It is useful in scenarios where you need to securely store user passwords by hashing them or validate user input passwords by comparing them with stored hashes.

Practical examples include:

  • Creating a hashed password before saving it to a database during user registration.
  • Verifying a user's login password by comparing it with the stored bcrypt hash.

Properties

Name Meaning
Password The password string to be hashed or verified.
Hash The bcrypt hash string to compare against (required only for verification operation).
Operation Choose between "Hash Password" (generate a bcrypt hash) or "Verify Password" (compare).
Salt Rounds Number of salt rounds used when hashing the password (only applicable for hashing).

Output

  • For the Hash Password operation, the output JSON contains:

    {
      "hash": "<bcrypt hashed password>"
    }
    

    This is the generated bcrypt hash of the input password.

  • For the Verify Password operation, the output JSON contains:

    {
      "match": true|false
    }
    

    This boolean indicates whether the provided password matches the given bcrypt hash.

The node does not output binary data.

Dependencies

  • Requires the bcryptjs library for hashing and verifying passwords.
  • 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 during verification will cause errors.
    • Using very high salt rounds may increase execution time significantly.
    • Empty or missing password inputs will result in errors or unexpected results.
  • Error messages:

    • Errors related to bcrypt hashing or comparison typically indicate invalid inputs or internal failures.
    • If the node is set to continue on failure, errors will be returned in the output JSON under the error field.

To resolve these issues:

  • Ensure the password and hash inputs are correctly provided and valid.
  • Use reasonable salt rounds (commonly 10).
  • Enable "Continue On Fail" if you want the workflow to proceed despite errors.

Links and References

Discussion