I would like to compute the bcrypt hash of my password.
Is there an open source command line tool that would do that ?
I would use this hash in the Syncthing configuration file (even if I know from here that I can reset the password by editing the config file to remove the user and password in the gui section, then restart Syncthing).
Best Answer
You can (ab)use
htpasswd
from apache-utils package, provided you have version 2.4 or higher.-b
takes the password from the second command argument-n
prints the hash to stdout instead of writing it to a file-B
instructs to use bcrypt-C 10
sets the bcrypt cost to 10The bare htpasswd command outputs in format <name>:<hash> followed by two newlines. Hence the empty string for name and
tr
stripping the colon and newlines.The command outputs bcrypt with
$2y$
prefix, which may be problem for some uses, but can easily be fixed by anothersed
since the OpenBSD variant using$2a$
is compatible with the fixed crypt_blowfish variant using$2y$
.Link to htpasswd man page: https://httpd.apache.org/docs/2.4/programs/htpasswd.html
Details about bcrypt variants: https://stackoverflow.com/a/36225192/6732096