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


PHP password_get_info函數代碼示例

本文整理匯總了PHP中password_get_info函數的典型用法代碼示例。如果您正苦於以下問題:PHP password_get_info函數的具體用法?PHP password_get_info怎麽用?PHP password_get_info使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: getHashInfo

 public function getHashInfo($hash)
 {
     $passwordGetInfoResult = password_get_info($hash);
     $identifier = $passwordGetInfoResult[HashInfo::ALGORITHM_ID_KEY];
     $name = $passwordGetInfoResult[HashInfo::ALGORITHM_NAME_KEY];
     $options = $passwordGetInfoResult[HashInfo::OPTIONS_KEY];
     return new HashInfo($identifier, $name, $options);
 }
開發者ID:jonasrudolph,項目名稱:php-component-password,代碼行數:8,代碼來源:PasswordService.php

示例2: update

 public function update($params)
 {
     if (isset($params['password'])) {
         if (!password_get_info($params['password'])['algo']) {
             $params['password'] = password_hash($params['password'], PASSWORD_DEFAULT);
         }
     }
     return parent::update($params);
 }
開發者ID:ngchie,項目名稱:system,代碼行數:9,代碼來源:Users.php

示例3: password_hashing

 public function password_hashing()
 {
     echo '<a href="http://www.codeigniter.com/user_guide/general/compatibility_functions.html">read</a>';
     $hash = 'password_hash';
     echo password_hash($hash, PASSWORD_DEFAULT);
     echo password_get_info($hash);
     echo password_needs_rehash($hash, PASSWORD_DEFAULT);
     echo password_verify('password_hash', $hash);
 }
開發者ID:psosulski,項目名稱:ci,代碼行數:9,代碼來源:Examples.php

示例4: __construct

 /**
  * @param string $password
  * @param boolean $automateHash
  */
 public function __construct($password, $automateHash = false)
 {
     $this->password = (string) $password;
     $info = password_get_info($this->password);
     $this->isHashed = 'unknown' !== $info['algoName'];
     if ($automateHash) {
         $this->hash();
     }
 }
開發者ID:thesoftwarefactoryuk,項目名稱:SenNetwork,代碼行數:13,代碼來源:Password.php

示例5: getInfo

 /**
  * @param string $hash
  * @return array
  */
 public function getInfo($hash)
 {
     $clear = Helpers::getHash($hash);
     $signatureLength = $this->getSignatureLength();
     $ivLength = $this->getIvLength();
     if (!$this->verifySignature(Helpers::substr($clear, 0, $signatureLength), Helpers::substr($clear, $signatureLength))) {
         throw new \Ark8\Passwords\Exceptions\SignatureException('Signature does not match.');
     }
     return password_get_info($this->decrypt(Helpers::substr($clear, $signatureLength, $ivLength), Helpers::substr($clear, $signatureLength + $ivLength)));
 }
開發者ID:ark8,項目名稱:passwords,代碼行數:14,代碼來源:Passwords.php

示例6: __construct

 /**
  * Constructor
  * 
  * @param string $hash
  */
 public function __construct($hash)
 {
     if (!is_string($hash)) {
         throw new DataType('hash', 'string', $hash);
     }
     $hashInfos = password_get_info($hash);
     if ($hashInfos['algo'] === 0) {
         throw new DataFormat('hash', 'a valid password hash', $hash);
     }
     $this->hash = $hash;
 }
開發者ID:broeser,項目名稱:wellid,代碼行數:16,代碼來源:Password.php

示例7: saving

 public function saving($model)
 {
     foreach ($this->options['fields'] as $field) {
         $password = (string) $model[$field];
         $info = password_get_info($password);
         if ($info['algo'] === 0) {
             // needs to be rehashed
             $model[$field] = password_hash($password, $this->options['algo'], $this->options['options']);
         }
     }
 }
開發者ID:xinix-technology,項目名稱:norm,代碼行數:11,代碼來源:Hashable.php

示例8: setHash

 public function setHash(string $hash) : PasswordInterface
 {
     if (empty($hash)) {
         throw new PasswordException('hash is empty');
     }
     if (password_get_info($hash)['algo'] === 0) {
         throw new PasswordException('The hash is not understandable by the underlying library');
     }
     $this->hashed = $hash;
     $this->isHashed = true;
     return $this;
 }
開發者ID:arabcoders,項目名稱:password,代碼行數:12,代碼來源:Password.php

示例9: __construct

 public function __construct($hashedPassword)
 {
     if (!is_string($hashedPassword) || empty($hashedPassword)) {
         throw new HashedPasswordException('The hashedPassword must be a non-empty string.');
     }
     $info = password_get_info($hashedPassword);
     if (empty($info) || !isset($info['algo']) || empty($info['algo'])) {
         throw new HashedPasswordException('The given hashedPassword (' . $hashedPassword . ') is invalid.');
     }
     $this->hashedPassword = $hashedPassword;
     $this->algo = $info['algo'];
 }
開發者ID:steve-rodrigue,項目名稱:authenticated-apis,代碼行數:12,代碼來源:ConcreteHashedPassword.php

示例10: canUpgradeInternalHash

 protected function canUpgradeInternalHash(PhutilOpaqueEnvelope $hash)
 {
     $info = password_get_info($hash->openEnvelope());
     // NOTE: If the costs don't match -- even if the new cost is lower than
     // the old cost -- count this as an upgrade. This allows costs to be
     // adjusted down and hashing to be migrated toward the new cost if costs
     // are ever configured too high for some reason.
     $cost = idx($info['options'], 'cost');
     if ($cost != $this->getBcryptCost()) {
         return true;
     }
     return false;
 }
開發者ID:pugong,項目名稱:phabricator,代碼行數:13,代碼來源:PhabricatorBcryptPasswordHasher.php

示例11: test_password_get_info

 /**
  * password_get_info() test
  *
  * Borrowed from PHP's own tests
  *
  * @depends	test_bootstrap
  */
 public function test_password_get_info()
 {
     $expected = array('algo' => 1, 'algoName' => 'bcrypt', 'options' => array('cost' => 10));
     // default
     $this->assertEquals($expected, password_get_info('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y'));
     $expected['options']['cost'] = 11;
     // cost
     $this->assertEquals($expected, password_get_info('$2y$11$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y'));
     $expected = array('algo' => 0, 'algoName' => 'unknown', 'options' => array());
     // invalid length
     $this->assertEquals($expected, password_get_info('$2y$11$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100'));
     // non-bcrypt
     $this->assertEquals($expected, password_get_info('$1$rasmusle$rISCgZzpwk3UhDidwXvin0'));
 }
開發者ID:saiful1105020,項目名稱:Under-Construction-Bracathon-Project-,代碼行數:21,代碼來源:password_test.php

示例12: getType

 public static function getType($hash)
 {
     $info = password_get_info($hash);
     if ($info['algo'] > 0) {
         return $info['algoName'];
     }
     if (substr($hash, 0, 3) == '$P$') {
         return 'phpass';
     }
     if (preg_match('/^[A-Z0-9]{32}\\:[A-Z0-9]{2}$/i', $hash) === 1) {
         return 'salt';
     }
     trigger_error('OSC\\OM\\Hash::getType() hash type not found for "' . substr($hash, 0, 5) . '"');
     return '';
 }
開發者ID:haraldpdl,項目名稱:oscommerce2,代碼行數:15,代碼來源:Hash.php

示例13: password_needs_rehash

 function password_needs_rehash($hash, $algorithm, $options = array())
 {
     $info = password_get_info($hash);
     if ($info['algo'] != $algorithm) {
         return true;
     }
     switch ($algorithm) {
         case PASSWORD_BCRYPT:
             $cost = isset($options['cost']) ? $options['cost'] : 10;
             if ($cost != $info['options']['cost']) {
                 return true;
             }
             break;
     }
     return false;
 }
開發者ID:juancamiloestela,項目名稱:RocketPHP,代碼行數:16,代碼來源:Helpers.php

示例14: verifyPassword

 public function verifyPassword($password)
 {
     if (!defined('PASSWORD_DEFAULT')) {
         require_once LIB_PATH . 'password_compat/password.php';
     }
     $this->loggedIn = password_verify($password, $this->PasswordHash) === true;
     if ($this->loggedIn) {
         // Verify password hash algorithm and strength requirements. -- cwells
         $passwordInfo = password_get_info($this->PasswordHash);
         if (password_needs_rehash($this->PasswordHash, PASSWORD_DEFAULT, $passwordInfo['options']) === true || $passwordInfo['options']['cost'] !== self::HASH_COST) {
             // No need to verify success here since we'll try again on the next login. -- cwells
             $this->setPassword($password);
         }
     }
     return $this->loggedIn;
 }
開發者ID:chriswells0,項目名稱:cwa-lib,代碼行數:16,代碼來源:User.php

示例15: passwordHash

 /**
  * Get the password hash if it is plaintext.
  * If hashed password is passed, so just returns it.
  *
  * @param RecoveryAccess|string $password Password to hash.
  *
  * @return string
  */
 public static function passwordHash($password)
 {
     if ($password instanceof RecoveryAccess) {
         $password = $password->password;
     }
     // Check password status.
     // It should detect if is a hashed password.
     $passwordStatus = password_get_info($password);
     if ($passwordStatus['algo'] === 0) {
         $hashOptions = [];
         // Overwrite the default cost.
         if (defined('VANILLA_RECOVERY_HASH_COST')) {
             $hashOptions['cost'] = VANILLA_RECOVERY_HASH_COST;
         }
         return (string) password_hash($password, PASSWORD_BCRYPT, $hashOptions);
     }
     return $password;
 }
開發者ID:VanillaPackage,項目名稱:vanilla-recovery,代碼行數:26,代碼來源:Helper.php


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