A oneliner with Perl does the trick:
1 |
perl -le 'print crypt("password", "salt")' |
The output you get should be placed in a file called htpasswd. The syntax is like so:
1 |
UserName:EncryptedPassword:YourComment |