本文整理汇总了PHP中Magento\Framework\Encryption\EncryptorInterface::encrypt方法的典型用法代码示例。如果您正苦于以下问题:PHP EncryptorInterface::encrypt方法的具体用法?PHP EncryptorInterface::encrypt怎么用?PHP EncryptorInterface::encrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Encryption\EncryptorInterface
的用法示例。
在下文中一共展示了EncryptorInterface::encrypt方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
/**
* Encrypt value before saving
*
* @return void
*/
public function beforeSave()
{
$this->_dataSaveAllowed = false;
$value = (string) $this->getValue();
// don't save value, if an obscured value was received. This indicates that data was not changed.
if (!preg_match('/^\\*+$/', $value) && !empty($value)) {
$this->_dataSaveAllowed = true;
$encrypted = $this->_encryptor->encrypt($value);
$this->setValue($encrypted);
}
}
示例2: beforeSave
/**
* Encrypt value before saving
*
* @return void
*/
public function beforeSave()
{
$value = (string) $this->getValue();
// don't change value, if an obscured value came
if (preg_match('/^\\*+$/', $this->getValue())) {
$value = $this->getOldValue();
}
if (!empty($value)) {
$encrypted = $this->_encryptor->encrypt($value);
if ($encrypted) {
$this->setValue($encrypted);
}
}
}
示例3: _reEncryptCreditCardNumbers
/**
* Gather saved credit card numbers from sales order payments and re-encrypt them
*
* @return void
*/
protected function _reEncryptCreditCardNumbers()
{
$table = $this->getTable('sales_order_payment');
$select = $this->getConnection()->select()->from($table, ['entity_id', 'cc_number_enc']);
$attributeValues = $this->getConnection()->fetchPairs($select);
// save new values
foreach ($attributeValues as $valueId => $value) {
$this->getConnection()->update($table, ['cc_number_enc' => $this->encryptor->encrypt($this->encryptor->decrypt($value))], ['entity_id = ?' => (int) $valueId]);
}
}
示例4: _beforeSave
/**
* Process additional data before save config
*
* @return $this
* @throws \Magento\Framework\Model\Exception
*/
protected function _beforeSave()
{
$value = $this->getValue();
if (is_array($value) && !empty($value['delete'])) {
$this->setValue('');
$this->_certFactory->create()->loadByWebsite($this->getScopeId())->delete();
}
if (!isset($_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value'])) {
return $this;
}
$tmpPath = $this->_tmpDirectory->getRelativePath($_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value']);
if ($tmpPath && $this->_tmpDirectory->isExist($tmpPath)) {
if (!$this->_tmpDirectory->stat($tmpPath)['size']) {
throw new \Magento\Framework\Model\Exception(__('The PayPal certificate file is empty.'));
}
$this->setValue($_FILES['groups']['name'][$this->getGroupId()]['fields'][$this->getField()]['value']);
$content = $this->_encryptor->encrypt($this->_tmpDirectory->readFile($tmpPath));
$this->_certFactory->create()->loadByWebsite($this->getScopeId())->setContent($content)->save();
}
return $this;
}
示例5: _saveConfig
/**
* Save the configuration value in both core and module db tables.
*
* @param $path
* @param $scopeId
* @param $value
* @param string $type
*/
protected function _saveConfig($path, $scopeId, $value, $type = self::TYPE_NORMAL)
{
// do not save config if path validation fails.
if (!($fullPathParts = $this->_validateFullPath($path))) {
return;
}
if ($type === self::TYPE_ENCRYPTED) {
$value = $this->_encryptor->encrypt($value);
}
// get the path from the parts of path
$path = implode('/', array_slice($fullPathParts, 1, 3));
$this->_coreConfigResource->saveConfig($path, $value, $fullPathParts[0], $scopeId);
$this->_configModel->setData(['scope_type' => $fullPathParts[0], 'scope_id' => $scopeId, 'path' => $path, 'value' => $value]);
$this->_configModel->save();
$this->_configModel->clearInstance();
}
示例6: encrypt
/**
* Encrypt data
*
* @param string $data
* @return string
*/
public function encrypt($data)
{
return $this->_encryptor->encrypt($data);
}
示例7: encryptPassword
/**
* Encrypt password
*
* @param string $password
* @return string
*/
public function encryptPassword($password)
{
return $this->_encryptor->encrypt($password);
}