本文整理汇总了PHP中Magento\Framework\Encryption\EncryptorInterface::validateKey方法的典型用法代码示例。如果您正苦于以下问题:PHP EncryptorInterface::validateKey方法的具体用法?PHP EncryptorInterface::validateKey怎么用?PHP EncryptorInterface::validateKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Encryption\EncryptorInterface
的用法示例。
在下文中一共展示了EncryptorInterface::validateKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeInternal
/**
* Process saving new encryption key
*
* @return void
*/
public function executeInternal()
{
try {
$key = null;
if (0 == $this->getRequest()->getPost('generate_random')) {
$key = $this->getRequest()->getPost('crypt_key');
if (empty($key)) {
throw new \Exception(__('Please enter an encryption key.'));
}
$this->encryptor->validateKey($key);
}
$newKey = $this->change->changeEncryptionKey($key);
$this->messageManager->addSuccessMessage(__('The encryption key has been changed.'));
if (!$key) {
$this->messageManager->addNoticeMessage(__('This is your new encryption key: <span style="font-family:monospace;">%1</span>. ' . 'Be sure to write it down and take good care of it!', $newKey));
}
$this->cache->clean();
} catch (\Exception $e) {
$this->messageManager->addErrorMessage($e->getMessage());
$this->_session->setFormData(['crypt_key' => $key]);
}
$this->_redirect('adminhtml/*/');
}
示例2: getValidEncryptionKey
/**
* Return a validated encryption key, generating a random one, if no value was initially provided
*
* @param string|null $key
* @return string
*/
public function getValidEncryptionKey($key = null)
{
if (!$key) {
$key = md5($this->mathRandom->getRandomString(10));
}
$this->_encryptor->validateKey($key);
return $key;
}