0

我正在用 PHP 为owncloud. 我从 CSV 文件中读取用户,然后将它们添加到owncloud database. 不过我的密码有问题。据我所知,owncloud 使用password_hash()with BCRYPT。我有passwordsalt,但我不确定如何将盐与password_hash().

有什么帮助吗?

4

2 回答 2

1

像这样在选项数组中使用盐

password_hash("rasmuslerdorf", PASSWORD_BCRYPT, array("cost" => 7, "salt" => "thisisyoursalt"));

但是使用自己的盐并不是一个好主意。让我们password_hash()为您的密码创建一个盐。password_hash()将为每个密码创建不同的盐。它将增加您的密码安全强度。

于 2016-01-07T18:48:58.393 回答
0

如果哈希是由password_hash()or产生的crypt(),那么盐就包含在生成的哈希值中。要根据此哈希检查密码,您可以使用函数password_verify(),该函数会自动提取盐和其他参数。

// Check if the hash of the entered login password, matches the stored hash.
// The salt and the cost factor will be extracted from $existingHashFromDb.
$isPasswordCorrect = password_verify($password, $existingHashFromDb);
于 2016-01-13T15:11:15.603 回答