I'm using a Debian 7.0 with PHP 5.3.3-7+squeeze14 with Suhosin-Patch (cli).
I need to build an htpasswd files from a form (data stored with MySQL).
I tried that but didn't work:
$hash = crypt($_POST['password'], base64_encode($_POST['password'])); //didn't work
$hash = crypt($_POST['password']); //didn't work
$hash = crypt($_POST['password'], substr($_POST['password'])); //didn't work
$cset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
$salt = "";
for ($i=0; $i<CRYPT_SALT_LENGTH; $i++) ``
$salt .= substr($cset, rand() & 63, 1);
$hash = crypt($_POST['password'], $salt); // didn't work
Someone can explain me how i can get the same result as htpasswd using PHP ? It's depend on my debian ? My /usr/bin/htpasswd script ?
Thanks !