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


PHP Crypt::multiKeyDecrypt方法代码示例

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


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

示例1: recoverFile

 /**
  * decrypt given file with recovery key and encrypt it again to the owner and his new key
  * @param string $file
  * @param string $privateKey recovery key to decrypt the file
  */
 private function recoverFile($file, $privateKey)
 {
     $sharingEnabled = \OCP\Share::isEnabled();
     // Find out who, if anyone, is sharing the file
     if ($sharingEnabled) {
         $result = \OCP\Share::getUsersSharingFile($file, $this->userId, true);
         $userIds = $result['users'];
         $userIds[] = $this->recoveryKeyId;
         if ($result['public']) {
             $userIds[] = $this->publicShareKeyId;
         }
     } else {
         $userIds = array($this->userId, $this->recoveryKeyId);
     }
     $filteredUids = $this->filterShareReadyUsers($userIds);
     $proxyStatus = \OC_FileProxy::$enabled;
     \OC_FileProxy::$enabled = false;
     //decrypt file key
     $encKeyfile = $this->view->file_get_contents($this->keyfilesPath . $file . ".key");
     $shareKey = $this->view->file_get_contents($this->shareKeysPath . $file . "." . $this->recoveryKeyId . ".shareKey");
     $plainKeyfile = Crypt::multiKeyDecrypt($encKeyfile, $shareKey, $privateKey);
     // encrypt file key again to all users, this time with the new public key for the recovered use
     $userPubKeys = Keymanager::getPublicKeys($this->view, $filteredUids['ready']);
     $multiEncKey = Crypt::multiKeyEncrypt($plainKeyfile, $userPubKeys);
     // write new keys to filesystem TDOO!
     $this->view->file_put_contents($this->keyfilesPath . $file . '.key', $multiEncKey['data']);
     foreach ($multiEncKey['keys'] as $userId => $shareKey) {
         $shareKeyPath = $this->shareKeysPath . $file . '.' . $userId . '.shareKey';
         $this->view->file_put_contents($shareKeyPath, $shareKey);
     }
     // Return proxy to original status
     \OC_FileProxy::$enabled = $proxyStatus;
 }
开发者ID:Combustible,项目名称:core,代码行数:38,代码来源:util.php

示例2: getKey

 /**
  * Fetch the plain encryption key for the file and set it as plainKey property
  * @internal param bool $generate if true, a new key will be generated if none can be found
  * @return bool true on key found and set, false on key not found and new key generated and set
  */
 public function getKey()
 {
     // Check if key is already set
     if (isset($this->plainKey) && isset($this->encKeyfile)) {
         return true;
     }
     // Fetch and decrypt keyfile
     // Fetch existing keyfile
     $util = new \OCA\Encryption\Util($this->rootView, $this->userId);
     $this->encKeyfile = Keymanager::getFileKey($this->rootView, $util, $this->relPath);
     // If a keyfile already exists
     if ($this->encKeyfile) {
         $shareKey = Keymanager::getShareKey($this->rootView, $this->keyId, $util, $this->relPath);
         // if there is no valid private key return false
         if ($this->privateKey === false) {
             // if private key is not valid redirect user to a error page
             \OCA\Encryption\Helper::redirectToErrorPage($this->session);
             return false;
         }
         if ($shareKey === false) {
             // if no share key is available redirect user to a error page
             \OCA\Encryption\Helper::redirectToErrorPage($this->session, \OCA\Encryption\Crypt::ENCRYPTION_NO_SHARE_KEY_FOUND);
             return false;
         }
         $this->plainKey = Crypt::multiKeyDecrypt($this->encKeyfile, $shareKey, $this->privateKey);
         return true;
     } else {
         $this->newFile = true;
         return false;
     }
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:36,代码来源:stream.php

示例3: recoverFile

 /**
  * decrypt given file with recovery key and encrypt it again to the owner and his new key
  * @param string $file
  * @param string $privateKey recovery key to decrypt the file
  */
 private function recoverFile($file, $privateKey)
 {
     $sharingEnabled = \OCP\Share::isEnabled();
     // Find out who, if anyone, is sharing the file
     if ($sharingEnabled) {
         $result = \OCP\Share::getUsersSharingFile($file, $this->userId, true);
         $userIds = $result['users'];
         $userIds[] = $this->recoveryKeyId;
         if ($result['public']) {
             $userIds[] = $this->publicShareKeyId;
         }
     } else {
         $userIds = array($this->userId, $this->recoveryKeyId);
     }
     $filteredUids = $this->filterShareReadyUsers($userIds);
     //decrypt file key
     $encKeyfile = Keymanager::getFileKey($this->view, $this, $file);
     $shareKey = Keymanager::getShareKey($this->view, $this->recoveryKeyId, $this, $file);
     $plainKeyfile = Crypt::multiKeyDecrypt($encKeyfile, $shareKey, $privateKey);
     // encrypt file key again to all users, this time with the new public key for the recovered use
     $userPubKeys = Keymanager::getPublicKeys($this->view, $filteredUids['ready']);
     $multiEncKey = Crypt::multiKeyEncrypt($plainKeyfile, $userPubKeys);
     Keymanager::setFileKey($this->view, $this, $file, $multiEncKey['data']);
     Keymanager::setShareKeys($this->view, $this, $file, $multiEncKey['keys']);
 }
开发者ID:riso,项目名称:owncloud-core,代码行数:30,代码来源:util.php

示例4: getKey

 /**
  * @brief Fetch the plain encryption key for the file and set it as plainKey property
  * @internal param bool $generate if true, a new key will be generated if none can be found
  * @return bool true on key found and set, false on key not found and new key generated and set
  */
 public function getKey()
 {
     // Check if key is already set
     if (isset($this->plainKey) && isset($this->encKeyfile)) {
         return true;
     }
     // Fetch and decrypt keyfile
     // Fetch existing keyfile
     $this->encKeyfile = Keymanager::getFileKey($this->rootView, $this->userId, $this->relPath);
     // If a keyfile already exists
     if ($this->encKeyfile) {
         // if there is no valid private key return false
         if ($this->privateKey === false) {
             // if private key is not valid redirect user to a error page
             \OCA\Encryption\Helper::redirectToErrorPage();
             return false;
         }
         $shareKey = Keymanager::getShareKey($this->rootView, $this->userId, $this->relPath);
         $this->plainKey = Crypt::multiKeyDecrypt($this->encKeyfile, $shareKey, $this->privateKey);
         return true;
     } else {
         return false;
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:29,代码来源:stream.php


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