當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PasswordHash::pbkdf2方法代碼示例

本文整理匯總了PHP中PasswordHash::pbkdf2方法的典型用法代碼示例。如果您正苦於以下問題:PHP PasswordHash::pbkdf2方法的具體用法?PHP PasswordHash::pbkdf2怎麽用?PHP PasswordHash::pbkdf2使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PasswordHash的用法示例。


在下文中一共展示了PasswordHash::pbkdf2方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validate_password

 public function validate_password($password, $correct_hash)
 {
     $params = explode(":", $correct_hash);
     if (count($params) < HASH_SECTIONS) {
         return false;
     }
     $pbkdf2 = base64_decode($params[HASH_PBKDF2_INDEX]);
     return PasswordHash::slow_equals($pbkdf2, PasswordHash::pbkdf2($params[HASH_ALGORITHM_INDEX], $password, $params[HASH_SALT_INDEX], (int) $params[HASH_ITERATION_INDEX], strlen($pbkdf2), true));
 }
開發者ID:croger46,項目名稱:oceanicdestiny,代碼行數:9,代碼來源:passwordHash.php

示例2: PasswordHash

 * POSSIBILITY OF SUCH DAMAGE.
 */
require_once 'PasswordHash.php';
$MyHash = new PasswordHash();
echo "Sample hash:\n";
$hash = $MyHash->create_hash("test_password");
echo $hash . "\n";
echo "Sample hash:\n";
$hash = $MyHash->create_hash("rugger31");
echo $hash . "\n";
echo "Sample hash:\n";
$hash = $MyHash->create_hash("Rugger31!");
echo $hash . "\n";
echo "\nTest results:\n";
// Test vector raw output.
$a = bin2hex($MyHash->pbkdf2("sha1", "password", "salt", 2, 20, true));
$b = "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957";
if ($a === $b) {
    echo "pass\n";
} else {
    echo "FAIL\n";
}
// Test vector hex output.
$a = $MyHash->pbkdf2("sha1", "password", "salt", 2, 20, false);
$b = "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957";
if ($a === $b) {
    echo "pass\n";
} else {
    echo "FAIL\n";
}
$hash_of_password = $MyHash->create_hash("password");
開發者ID:shwetazutshi,項目名稱:Msu2u-Api,代碼行數:31,代碼來源:hash_test.php


注:本文中的PasswordHash::pbkdf2方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。