當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。