On my linux machine, I'm able to generate bcrypt hash from command line using htpassword
htpasswd -bnBC 10 "" password | tr -d ':\n'
however it generates "$2y$" but I need "$2a$" (bcrypt 2a). How can I achieve it?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You haven't mentioned your use case, but generally, if it's a modern htpasswd implementation, it's generating a $2a$-compatible hash (null-terminated, UTF-8 encoded), even though it's using $2y$ to label the variant.
In other words, you could probably literally replace the 2y with 2a, and it should work.
This StackOverflow answer goes into more detail:
There is no difference between 2a, 2x, 2y, and 2b. If you wrote your implementation correctly, they all output the same result.
All of the pre-modern variants are rooted in buggy implementations - either in OpenBSD, or in PHP's
crypt_blowfish. If you're working with any modern platform, the hash formats should now be interchangeable.
If you actually need to generate one of the pre-modern (buggy) hashes, you'll have to find an implementation from before the bug was fixed.