To create an htpasswd file (for htaccess “authentication”) using openssl:

$ printf "foo:$(openssl passwd -apr1 PASSWORD)\n" >> .htpasswd

If need to use crypt:

$ printf "foo:$(openssl passwd -crypt PASSWORD)\n" >> .htpasswd