本文整理汇总了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);
}
示例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);
}
}
示例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();
}
}
}
示例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);
}
示例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.'));
}
}
}
}
示例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;
}
示例7: _getEncodedPassword
/**
* Retrieve encoded password
*
* @param string $password
* @return string
*/
protected function _getEncodedPassword($password)
{
return $this->_encryptor->getHash($password, true);
}
示例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);
}
示例9: generatePassword
/**
* Generate password string
*
* @return string
*/
protected function generatePassword()
{
return $this->encryptor->getHash($this->data[self::KEY_PASSWORD], true);
}
示例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);
}