当前位置: 首页>>代码示例>>PHP>>正文


PHP PasswordHash::hashPassword方法代码示例

本文整理汇总了PHP中PasswordHash::hashPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP PasswordHash::hashPassword方法的具体用法?PHP PasswordHash::hashPassword怎么用?PHP PasswordHash::hashPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PasswordHash的用法示例。


在下文中一共展示了PasswordHash::hashPassword方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hashString

 /**
  * @param $string
  * @throws Exception
  * @return string
  */
 public function hashString($string)
 {
     $hasher = new \PasswordHash($this->_iterationCount, false);
     $hashAndType = $hasher->hashPassword($string);
     $check = $hasher->checkPassword($string, $hashAndType['hash']);
     if (!$check) {
         throw new Exception(Craft::t('Could not hash the given string.'));
     }
     return $hashAndType;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:15,代码来源:SecurityService.php

示例2: beforeSave

 public function beforeSave()
 {
     $ph = new PasswordHash(Yii::app()->params['phpass']['iteration_count_log2'], Yii::app()->params['phpass']['portable_hashes']);
     //add the password hash if it's a new record
     if ($this->getIsNewRecord()) {
         $this->user_password = $ph->hashPassword($this->Password);
     } elseif (!empty($this->Password) && !empty($this->PasswordConfirm) && $this->Password === $this->PasswordConfirm) {
         $this->user_password = $ph->hashPassword($this->Password);
     } elseif (!empty($this->ResetPassword)) {
         $this->user_password = $ph->hashPassword($this->ResetPassword);
     }
     //$this->items = implode(', ', $this->items);
     return parent::beforeSave();
 }
开发者ID:noonnightcoder,项目名称:bakou-pos-apsara,代码行数:14,代码来源:RbacUser.php

示例3: getUserData

 public function getUserData($password)
 {
     $password = PasswordHash::hashPassword($this->validateInput("guests", $password, "password"));
     return $this->loadUser($this->query(DBService::SELECT, "guests", array("COLUMNS" => array("`id`", "`Household name`", "`Has RSVPed`", "`Friend login` as `isFriend`", "(`Ceremony adults invited` + `Ceremony children invited`) as `ceremony invited`", "(`Reception adults invited` + `Reception children invited`) as `reception invited`", "(`Havdalah adults invited` + `Havdalah children invited`) as `havdalah invited`"), "WHERE" => "`password` = '" . $password . "'")));
 }
开发者ID:micahherstand,项目名称:shalomshanti,代码行数:5,代码来源:GuestService.php

示例4: setPassword

	/**
	 * Set the user's password using the necessary hashing
	 *
	 * @param $password
	 *
	 * @return bool|string True/False on success or failure, a string if on error.
	 */
	public function setPassword($password) {
		$isvalid = $this->validatePassword($password);

		if($isvalid !== true){
			// Core validation returned a string.... it's INVALID!
			return $isvalid;
		}

		// hash the password.
		$hasher = new \PasswordHash(datastore::HASH_ITERATIONS);
		$password = $hasher->hashPassword($password);

		// Still here?  Then try to set it.
		$this->_usermodel->set('password', $password);
		$this->_usermodel->set('last_password', DateTime::NowGMT());
		return true;
	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:24,代码来源:datastore.php

示例5: testGeneratedPasswordEncryption

 public function testGeneratedPasswordEncryption()
 {
     $sPassword = PasswordHash::generatePassword();
     $sHash = PasswordHash::hashPassword($sPassword);
     $this->assertSame(true, PasswordHash::comparePassword($sPassword, $sHash));
 }
开发者ID:rapila,项目名称:cms-base,代码行数:6,代码来源:PasswordHashTests.php

示例6: setNewPassword

 /**
  * Set a new password to an user account
  *
  * @param string $token Password token used to reset the account
  * @param string $password New password
  * @return bool
  */
 public function setNewPassword($token, $password)
 {
     $changed = false;
     $this->_db->beginTransaction();
     try {
         $tokenData = $this->_db->fetchFirstRequest('getPasswordResetByToken', array(':token' => $token));
         if (!empty($tokenData)) {
             $hasher = new PasswordHash(8, false);
             $hashedPassword = $hasher->hashPassword($password);
             if (!empty($hashedPassword)) {
                 $this->_db->executeRequest('changeUserPassword', array(':password' => $hashedPassword, ':id' => $tokenData['user_id']));
                 $this->_db->executeRequest('cleanTokens', array(':userId' => $tokenData['user_id']));
                 $changed = true;
             } else {
                 $this->_messenger->add('error', $this->_lang->get('passwordMiscError'));
             }
         }
     } catch (Exception $e) {
         $this->_db->rollBack();
         throw $e;
     }
     $this->_db->commit();
     return $changed;
 }
开发者ID:JLacoude,项目名称:Atrexus,代码行数:31,代码来源:User.php


注:本文中的PasswordHash::hashPassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。