What are the differences in encryption between PHP and htpasswd, and how can they be reconciled?

The main difference in encryption between PHP and htpasswd is the hashing algorithm used. PHP typically uses functions like password_hash() with bcrypt, while htpasswd uses MD5 or SHA. To reconcile this, you can use PHP to generate the hashed password in the same format as htpasswd by specifying the algorithm and options.

$password = 'password123';
$hashed_password = crypt($password, '$apr1$' . substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789'), 0, 8) . '$');
echo $hashed_password;