0

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

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

我试过了,但没有奏效:

$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 脚本?

谢谢 !

4

0 回答 0