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


PHP Crypt::getDecrypt方法代码示例

本文整理汇总了PHP中Crypt::getDecrypt方法的典型用法代码示例。如果您正苦于以下问题:PHP Crypt::getDecrypt方法的具体用法?PHP Crypt::getDecrypt怎么用?PHP Crypt::getDecrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Crypt的用法示例。


在下文中一共展示了Crypt::getDecrypt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processEncrypted

 /**
  * Procesar los datos encriptados y añadirlos al árbol DOM desencriptados
  */
 protected function processEncrypted()
 {
     foreach ($this->_xmlDOM->getElementsByTagName('Data') as $node) {
         $data = base64_decode($node->nodeValue);
         $iv = base64_decode($node->getAttribute('iv'));
         $xmlDecrypted = Crypt::getDecrypt($data, $iv, $this->getImportPass());
         $newXmlData = new \DOMDocument();
         //            $newXmlData->preserveWhiteSpace = true;
         $newXmlData->loadXML($xmlDecrypted);
         $newNode = $this->_xmlDOM->importNode($newXmlData->documentElement, TRUE);
         $this->_xmlDOM->documentElement->appendChild($newNode);
     }
     // Eliminar los datos encriptados tras desencriptar los mismos
     if ($this->_xmlDOM->getElementsByTagName('Data')->length > 0) {
         $nodeData = $this->_xmlDOM->getElementsByTagName('Encrypted')->item(0);
         $nodeData->parentNode->removeChild($nodeData);
     }
 }
开发者ID:bitking,项目名称:sysPass,代码行数:21,代码来源:SyspassImport.class.php

示例2: updateCustomFieldsCrypt

 /**
  * Actualizar los datos encriptados con una nueva clave
  *
  * @param string $currentMasterPass La clave maestra actual
  * @param string $newMasterPassword La nueva clave maestra
  * @return bool
  * @throws SPException
  */
 public static function updateCustomFieldsCrypt($currentMasterPass, $newMasterPassword)
 {
     $Log = new Log();
     $Log->setAction(_('Campos Personalizados'));
     $query = 'SELECT customfielddata_id, customfielddata_data, customfielddata_iv FROM customFieldsData';
     DB::setReturnArray();
     $queryRes = DB::getResults($query, __FUNCTION__);
     if ($queryRes === false) {
         $Log->addDescription(_('Fin'));
         $Log->writeLog();
         return true;
     }
     $Log->addDescription(_('Actualizando datos encriptados'));
     $Log->writeLog(true);
     $errors = array();
     $success = array();
     foreach ($queryRes as $customField) {
         $fieldData = Crypt::getDecrypt($customField->customfielddata_data, $customField->customfielddata_iv, $currentMasterPass);
         $fieldCryptData = Crypt::encryptData($fieldData, $newMasterPassword);
         $query = 'UPDATE customFieldsData SET ' . 'customfielddata_data = :data, ' . 'customfielddata_iv = :iv ' . 'WHERE customfielddata_id = :id ';
         $data['id'] = $customField->customfielddata_id;
         $data['data'] = $fieldCryptData['data'];
         $data['iv'] = $fieldCryptData['iv'];
         if (DB::getQuery($query, __FUNCTION__, $data) === false) {
             $errors[] = $customField->customfielddata_id;
         } else {
             $success[] = $customField->customfielddata_id;
         }
     }
     if (count($errors) > 0) {
         $Log->addDescription(_('Registros no actualizados') . ': ' . implode(',', $errors));
         $Log->writeLog(true);
     }
     if (count($success) > 0) {
         $Log->addDescription(_('Registros actualizados') . ': ' . implode(',', $success));
         $Log->writeLog(true);
     }
     $Log->addDescription(_('Fin'));
     $Log->writeLog();
     return count($errors) === 0;
 }
开发者ID:bitking,项目名称:sysPass,代码行数:49,代码来源:CustomFields.class.php

示例3: getSessionMPass

 /**
  * Desencriptar la clave maestra de la sesión.
  *
  * @return string con la clave maestra
  */
 public static function getSessionMPass()
 {
     $cryptPass = Crypt::generateAesKey(session_id());
     return Crypt::getDecrypt(Session::getMPass(), Session::getMPassIV(), $cryptPass);
 }
开发者ID:bitking,项目名称:sysPass,代码行数:10,代码来源:SessionUtil.class.php

示例4: getUserMPass

 /**
  * Desencriptar la clave maestra del usuario para la sesión.
  *
  * @param bool $showPass opcional, para devolver la clave desencriptada
  * @return false|string Devuelve bool se hay error o string si se devuelve la clave
  */
 public function getUserMPass($showPass = false)
 {
     $query = 'SELECT user_mPass, user_mIV FROM usrData WHERE user_id = :id LIMIT 1';
     $data['id'] = $this->_userId;
     $queryRes = DB::getResults($query, __FUNCTION__, $data);
     if ($queryRes === false) {
         return false;
     }
     if ($queryRes->user_mPass && $queryRes->user_mIV) {
         $clearMasterPass = Crypt::getDecrypt($queryRes->user_mPass, $queryRes->user_mIV, $this->getCypherPass());
         if (!$clearMasterPass) {
             return false;
         }
         return $showPass === true ? $clearMasterPass : SessionUtil::saveSessionMPass($clearMasterPass);
     }
     return false;
 }
开发者ID:bitking,项目名称:sysPass,代码行数:23,代码来源:User.class.php

示例5: updateAccountsMasterPass

 /**
  * Actualiza las claves de todas las cuentas con la nueva clave maestra.
  *
  * @param string $currentMasterPass con la clave maestra actual
  * @param string $newMasterPass     con la nueva clave maestra
  * @param string $newHash           con el nuevo hash de la clave maestra
  * @return bool
  */
 public function updateAccountsMasterPass($currentMasterPass, $newMasterPass, $newHash = null)
 {
     $accountsOk = array();
     $userId = Session::getUserId();
     $demoEnabled = Util::demoIsEnabled();
     $errorCount = 0;
     $Log = new Log(_('Actualizar Clave Maestra'));
     $Log->addDescription(_('Inicio'));
     $Log->writeLog();
     $Log->resetDescription();
     if (!Crypt::checkCryptModule()) {
         $Log->addDescription(_('Error en el módulo de encriptación'));
         $Log->writeLog();
         return false;
     }
     $accountsPass = $this->getAccountsPassData();
     if (!$accountsPass) {
         $Log->addDescription(_('Error al obtener las claves de las cuentas'));
         $Log->writeLog();
         return false;
     }
     foreach ($accountsPass as $account) {
         $this->setAccountId($account->account_id);
         $this->setAccountUserEditId($userId);
         // No realizar cambios si está en modo demo
         if ($demoEnabled) {
             $accountsOk[] = $this->getAccountId();
             continue;
         }
         if (strlen($account->account_pass) === 0) {
             $Log->addDescription(_('Clave de cuenta vacía') . ' (' . $account->account_id . ') ' . $account->account_name);
             continue;
         }
         if (strlen($account->account_IV) < 32) {
             $Log->addDescription(_('IV de encriptación incorrecto') . ' (' . $account->account_id . ') ' . $account->account_name);
         }
         $decryptedPass = Crypt::getDecrypt($account->account_pass, $account->account_IV);
         $this->setAccountPass(Crypt::mkEncrypt($decryptedPass, $newMasterPass));
         $this->setAccountIV(Crypt::$strInitialVector);
         if ($this->getAccountPass() === false) {
             $errorCount++;
             $Log->addDescription(_('No es posible desencriptar la clave de la cuenta') . ' (' . $account->account_id . ') ' . $account->account_name);
             continue;
         }
         if (!$this->updateAccountPass(true)) {
             $errorCount++;
             $Log->addDescription(_('Fallo al actualizar la clave de la cuenta') . ' (' . $this->getAccountId() . ') ' . $account->acchistory_name);
             continue;
         }
         $accountsOk[] = $this->getAccountId();
     }
     // Vaciar el array de mensajes de log
     if (count($Log->getDescription()) > 0) {
         $Log->writeLog();
         $Log->resetDescription();
     }
     if ($accountsOk) {
         $Log->addDescription(_('Cuentas actualizadas') . ': ' . implode(',', $accountsOk));
         $Log->writeLog();
         $Log->resetDescription();
     }
     $Log->addDescription(_('Fin'));
     $Log->writeLog();
     Email::sendEmail($Log);
     return true;
 }
开发者ID:bitking,项目名称:sysPass,代码行数:74,代码来源:Account.class.php

示例6: getTempMasterPass

 /**
  * Devuelve la clave maestra que ha sido encriptada con la clave temporal
  *
  * @param $pass string con la clave utilizada para encriptar
  * @return string con la clave maestra desencriptada
  */
 public static function getTempMasterPass($pass)
 {
     $passLogin = hex2bin(ConfigDB::getValue('tempmaster_pass'));
     $passLoginIV = hex2bin(ConfigDB::getValue('tempmaster_passiv'));
     return Crypt::getDecrypt($passLogin, $passLoginIV, $pass);
 }
开发者ID:bitking,项目名称:sysPass,代码行数:12,代码来源:CryptMasterPass.class.php


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