# file: gen.py
import bcrypt
def encrypt_password(username, password):
bcrypted = bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt(rounds=12)).decode("utf-8")
return f"{username}:{bcrypted}"
print(encrypt_password("client", "ClientO98"))
$ python gen.py > passwd
$ htpasswd -vb passwd client ClientO98
Password for user client correct.
$ htpasswd -vb passwd client ClientO99
password verification failed
$ htpasswd -vb passwd client1 ClientO98
User client1 not found
The prefix arg is indeed much cleaner. Thanks.