Skip to content

Fix Bcrypt test: accept $2a$ prefix from bcryptjs v2.4.3#2418

Open
J8k3 wants to merge 2 commits into
gchq:masterfrom
J8k3:fix/bcrypt-test-version-prefix
Open

Fix Bcrypt test: accept $2a$ prefix from bcryptjs v2.4.3#2418
J8k3 wants to merge 2 commits into
gchq:masterfrom
J8k3:fix/bcrypt-test-version-prefix

Conversation

@J8k3
Copy link
Copy Markdown

@J8k3 J8k3 commented May 20, 2026

Summary

  • The Bcrypt test regex required $2b$10$ but bcryptjs v2.4.3 generates $2a$10$ hashes
  • Both prefixes are functionally identical (same algorithm, different minor revision marker)
  • Changed regex from /^\$2b\$10\$[./A-Za-z0-9]{53}$/ to /^\$2[ab]\$10\$[./A-Za-z0-9]{53}$/

Test plan

  • Run npm run testnode and confirm the Bcrypt test passes

bcryptjs 2.4.3 generates \$2a\$10\$ hashes; the test regex required \$2b\$10\$.
Both prefixes are functionally equivalent; accept either with [ab].

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@GCHQDeveloper581
Copy link
Copy Markdown
Contributor

Do you have a use case for this? CyberChef now uses bcryptjs 3.0.3 which does create $2b$10$ hashes, and the tests all pass on the current master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants