如何使用PHP获得与htpasswd相同的结果?

时间:2013-10-16 12:21:44

标签: php crypt .htpasswd

我正在使用Debian 7.0和PHP 5.3.3-7 + squeeze14和Suhosin-Patch(cli)。

我需要从表单构建一个htpasswd文件(用MySQL存储的数据)。

我尝试了但没有奏效:

$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

有人可以解释我如何使用PHP获得与htpasswd相同的结果?这取决于我的debian?我的/ usr / bin / htpasswd脚本?

谢谢!

0 个答案:

没有答案
相关问题