当前位置: 首页>>代码示例>>PHP>>正文


PHP Crypt::encryptData方法代码示例

本文整理汇总了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();
     }
 }
开发者ID:bitking,项目名称:sysPass,代码行数:33,代码来源:KeepassImport.class.php

示例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));
         }
     }
 }
开发者ID:bitking,项目名称:sysPass,代码行数:46,代码来源:CsvImportBase.class.php

示例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;
 }
开发者ID:bitking,项目名称:sysPass,代码行数:21,代码来源:CustomFields.class.php

示例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();
     }
 }
开发者ID:bitking,项目名称:sysPass,代码行数:24,代码来源:KeepassXImport.class.php


注:本文中的Crypt::encryptData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。