本文整理汇总了PHP中Crypt::encryptData方法的典型用法代码示例。如果您正苦于以下问题:PHP Crypt::encryptData方法的具体用法?PHP Crypt::encryptData怎么用?PHP Crypt::encryptData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crypt
的用法示例。
在下文中一共展示了Crypt::encryptData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processAccounts
/**
* Obtener los datos de las entradas de KeePass.
*
* @param \SimpleXMLElement $entries El objeto XML con las entradas
*/
protected function processAccounts(\SimpleXMLElement $entries)
{
foreach ($entries as $entry) {
foreach ($entry->String as $account) {
$value = isset($account->Value) ? (string) $account->Value : '';
switch ($account->Key) {
case 'Notes':
$this->setAccountNotes($value);
break;
case 'Password':
$passData = Crypt::encryptData($value);
$this->setAccountPass($passData['data']);
$this->setAccountPassIV($passData['iv']);
break;
case 'Title':
$this->setAccountName($value);
break;
case 'URL':
$this->setAccountUrl($value);
break;
case 'UserName':
$this->setAccountLogin($value);
break;
}
}
$this->addAccount();
}
}
示例2: processAccounts
/**
* Obtener los datos de las entradas de sysPass y crearlas
*
* @throws SPException
*/
protected function processAccounts()
{
$line = 0;
$lines = $this->_file->getFileContent();
foreach ($lines as $data) {
$line++;
$fields = explode($this->_fieldDelimiter, $data);
$numfields = count($fields);
// Comprobar el número de campos de la línea
if ($numfields !== $this->_numFields) {
throw new SPException(SPException::SP_CRITICAL, sprintf(_('El número de campos es incorrecto (%d)'), $numfields), sprintf(_('Compruebe el formato del archivo CSV en línea %s'), $line));
}
// Eliminar las " del principio/fin de los campos
array_walk($fields, function (&$value, $key) {
$value = trim($value, '"');
});
// Asignar los valores del array a variables
list($accountName, $customerName, $categoryName, $url, $login, $password, $notes) = $fields;
// Obtener los ids de cliente, categoría y la clave encriptada
$customerId = Customer::addCustomerReturnId($customerName);
$categoryId = Category::addCategoryReturnId($categoryName);
$pass = Crypt::encryptData($password);
// Crear la nueva cuenta
$this->setAccountName($accountName);
$this->setAccountLogin($login);
$this->setCategoryId($categoryId);
$this->setCustomerId($customerId);
$this->setAccountNotes($notes);
$this->setAccountUrl($url);
$this->setAccountPass($pass['data']);
$this->setAccountPassIV($pass['iv']);
if (!$this->addAccount()) {
$log = new Log(_('Importar Cuentas'));
$log->addDescription(_('Error importando cuenta'));
$log->addDescription(sprintf(_('Error procesando línea %s'), $line));
$log->writeLog();
} else {
Log::writeNewLog(_('Importar Cuentas'), sprintf(_('Cuenta importada: %s'), $accountName));
}
}
}
示例3: addCustomField
/**
* Añade los datos de un campo personalizado de un elemento
*
* @return bool
* @throws SPException
*/
public function addCustomField()
{
if (empty($this->_value)) {
return true;
}
$cryptData = Crypt::encryptData($this->_value);
$query = 'INSERT INTO customFieldsData SET ' . 'customfielddata_itemId = :itemid, ' . 'customfielddata_moduleId = :moduleid, ' . 'customfielddata_defId = :defid, ' . 'customfielddata_data = :data, ' . 'customfielddata_iv = :iv';
$data['itemid'] = $this->_itemId;
$data['moduleid'] = $this->_module;
$data['defid'] = $this->_id;
$data['data'] = $cryptData['data'];
$data['iv'] = $cryptData['iv'];
$queryRes = DB::getQuery($query, __FUNCTION__, $data);
return $queryRes;
}
示例4: processAccounts
/**
* Obtener los datos de las entradas de KeePass.
*
* @param \SimpleXMLElement $entries El objeto XML con las entradas
* @param string $groupName con nombre del grupo a procesar
*/
protected function processAccounts(\SimpleXMLElement $entries, $groupName)
{
foreach ($entries as $entry) {
$notes = isset($entry->comment) ? (string) $entry->comment : '';
$password = isset($entry->password) ? (string) $entry->password : '';
$name = isset($entry->title) ? (string) $entry->title : '';
$url = isset($entry->url) ? (string) $entry->url : '';
$username = isset($entry->username) ? (string) $entry->username : '';
$passData = Crypt::encryptData($password);
$this->setAccountPass($passData['data']);
$this->setAccountPassIV($passData['iv']);
$this->setAccountNotes($notes);
$this->setAccountName($name);
$this->setAccountUrl($url);
$this->setAccountLogin($username);
$this->addAccount();
}
}