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


PHP EncryptorInterface::getHash方法代码示例

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


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

示例1: generatePublicHash

 /**
  * Generate vault payment public hash
  *
  * @param PaymentTokenInterface $paymentToken
  * @return string
  */
 protected function generatePublicHash(PaymentTokenInterface $paymentToken)
 {
     $hashKey = $paymentToken->getGatewayToken();
     if ($paymentToken->getCustomerId()) {
         $hashKey = $paymentToken->getCustomerId();
     }
     $hashKey .= $paymentToken->getPaymentMethodCode() . $paymentToken->getType() . $paymentToken->getTokenDetails();
     return $this->encryptor->getHash($hashKey);
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:15,代码来源:AfterPaymentSaveObserver.php

示例2: execute

 /**
  * Upgrade customer password hash when customer has logged in
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $password = $observer->getEvent()->getData('password');
     /** @var \Magento\Customer\Model\Customer $model */
     $model = $observer->getEvent()->getData('model');
     $customer = $this->customerRepository->getById($model->getId());
     $customerSecure = $this->customerRegistry->retrieveSecureData($model->getId());
     if (!$this->encryptor->validateHashVersion($customerSecure->getPasswordHash(), true)) {
         $customerSecure->setPasswordHash($this->encryptor->getHash($password, true));
         $this->customerRepository->save($customer);
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:UpgradeCustomerPasswordObserver.php

示例3: execute

 /**
  * Save current admin password to prevent its usage when changed in the future.
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     /* @var $user \Magento\User\Model\User */
     $user = $observer->getEvent()->getObject();
     if ($user->getId()) {
         $password = $user->getCurrentPassword();
         $passwordLifetime = $this->observerConfig->getAdminPasswordLifetime();
         if ($passwordLifetime && $password && !$user->getForceNewPassword()) {
             $passwordHash = $this->encryptor->getHash($password, false);
             $this->userResource->trackPassword($user, $passwordHash, $passwordLifetime);
             $this->messageManager->getMessages()->deleteMessageByIdentifier('magento_user_password_expired');
             $this->authSession->unsPciAdminUserIsPasswordExpired();
         }
     }
 }
开发者ID:vv-team,项目名称:foodo,代码行数:21,代码来源:TrackAdminNewPasswordObserver.php

示例4: getSecretKey

 /**
  * Generate secret key for controller and action based on form key
  *
  * @param string $routeName
  * @param string $controller Controller name
  * @param string $action Action name
  * @return string
  */
 public function getSecretKey($routeName = null, $controller = null, $action = null)
 {
     $salt = $this->formKey->getFormKey();
     $request = $this->_getRequest();
     if (!$routeName) {
         if ($request->getBeforeForwardInfo('route_name') !== null) {
             $routeName = $request->getBeforeForwardInfo('route_name');
         } else {
             $routeName = $request->getRouteName();
         }
     }
     if (!$controller) {
         if ($request->getBeforeForwardInfo('controller_name') !== null) {
             $controller = $request->getBeforeForwardInfo('controller_name');
         } else {
             $controller = $request->getControllerName();
         }
     }
     if (!$action) {
         if ($request->getBeforeForwardInfo('action_name') !== null) {
             $action = $request->getBeforeForwardInfo('action_name');
         } else {
             $action = $request->getActionName();
         }
     }
     $secret = $routeName . $controller . $action . $salt;
     return $this->_encryptor->getHash($secret);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:36,代码来源:Url.php

示例5: execute

 /**
  * Harden admin password change.
  *
  * New password must be minimum 7 chars length and include alphanumeric characters
  * The password is compared to at least last 4 previous passwords to prevent setting them again
  *
  * @param EventObserver $observer
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function execute(EventObserver $observer)
 {
     /* @var $user \Magento\User\Model\User */
     $user = $observer->getEvent()->getObject();
     if ($user->getNewPassword()) {
         $password = $user->getNewPassword();
     } else {
         $password = $user->getPassword();
     }
     if ($password && !$user->getForceNewPassword() && $user->getId()) {
         if ($this->encryptor->isValidHash($password, $user->getOrigData('password'))) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Sorry, but this password has already been used. Please create another.'));
         }
         // check whether password was used before
         $passwordHash = $this->encryptor->getHash($password, false);
         foreach ($this->userResource->getOldPasswords($user) as $oldPasswordHash) {
             if ($passwordHash === $oldPasswordHash) {
                 throw new \Magento\Framework\Exception\LocalizedException(__('Sorry, but this password has already been used. Please create another.'));
             }
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:32,代码来源:CheckAdminPasswordChangeObserver.php

示例6: saveTokenWithPaymentLink

 /**
  * @param PaymentTokenInterface $token
  * @param OrderPaymentInterface $payment
  * @return bool
  */
 public function saveTokenWithPaymentLink(PaymentTokenInterface $token, OrderPaymentInterface $payment)
 {
     $tokenDuplicate = $this->getByPublicHash($token->getPublicHash(), $token->getCustomerId());
     if (!empty($tokenDuplicate)) {
         if ($token->getIsVisible()) {
             $token->setEntityId($tokenDuplicate->getEntityId());
         } else {
             $token->setPublicHash($this->encryptor->getHash($token->getPublicHash() . $token->getCreatedAt()));
         }
     }
     $this->paymentTokenRepository->save($token);
     $result = $this->addLinkToOrderPayment($token->getEntityId(), $payment->getEntityId());
     return $result;
 }
开发者ID:uibar,项目名称:lavinia2,代码行数:19,代码来源:PaymentTokenManagement.php

示例7: _getEncodedPassword

 /**
  * Retrieve encoded password
  *
  * @param string $password
  * @return string
  */
 protected function _getEncodedPassword($password)
 {
     return $this->_encryptor->getHash($password, true);
 }
开发者ID:razbakov,项目名称:magento2,代码行数:10,代码来源:User.php

示例8: getPasswordHash

 /**
  * Return hashed password, which can be directly saved to database.
  *
  * @param string $password
  * @return string
  */
 public function getPasswordHash($password)
 {
     return $this->encryptor->getHash($password);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:AccountManagement.php

示例9: generatePassword

 /**
  * Generate password string
  *
  * @return string
  */
 protected function generatePassword()
 {
     return $this->encryptor->getHash($this->data[self::KEY_PASSWORD], true);
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:9,代码来源:AdminAccount.php

示例10: hashPassword

 /**
  * Hash customer password
  *
  * @param string $password
  * @param bool|int|string $salt
  * @return string
  */
 public function hashPassword($password, $salt = true)
 {
     return $this->_encryptor->getHash($password, $salt);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:Customer.php


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