当前位置: 首页>>代码示例>>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;未经允许,请勿转载。