當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Crypt::isHeader方法代碼示例

本文整理匯總了PHP中Crypt::isHeader方法的典型用法代碼示例。如果您正苦於以下問題:PHP Crypt::isHeader方法的具體用法?PHP Crypt::isHeader怎麽用?PHP Crypt::isHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Crypt的用法示例。


在下文中一共展示了Crypt::isHeader方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: containHeader

 /**
  * check if encrypted file contain a encryption header
  *
  * @param string $path
  * @return boolean
  */
 private function containHeader($path)
 {
     // Disable encryption proxy to read the raw data
     $proxyStatus = \OC_FileProxy::$enabled;
     \OC_FileProxy::$enabled = false;
     $isHeader = false;
     $handle = $this->view->fopen($path, 'r');
     if (is_resource($handle)) {
         $firstBlock = fread($handle, Crypt::BLOCKSIZE);
         $isHeader = Crypt::isHeader($firstBlock);
     }
     \OC_FileProxy::$enabled = $proxyStatus;
     return $isHeader;
 }
開發者ID:Combustible,項目名稱:core,代碼行數:20,代碼來源:util.php

示例2: stream_read

 /**
  * @param int $count
  * @return bool|string
  * @throws \OCA\Encryption\Exceptions\EncryptionException
  */
 public function stream_read($count)
 {
     $this->writeCache = '';
     if ($count !== Crypt::BLOCKSIZE) {
         \OCP\Util::writeLog('Encryption library', 'PHP "bug" 21641 no longer holds, decryption system requires refactoring', \OCP\Util::FATAL);
         throw new \OCA\Encryption\Exceptions\EncryptionException('expected a blog size of 8192 byte', 20);
     }
     // Get the data from the file handle
     $data = fread($this->handle, $count);
     // if this block contained the header we move on to the next block
     if (Crypt::isHeader($data)) {
         $data = fread($this->handle, $count);
     }
     $result = null;
     if (strlen($data)) {
         if (!$this->getKey()) {
             // Error! We don't have a key to decrypt the file with
             throw new \Exception('Encryption key not found for "' . $this->rawPath . '" during attempted read via stream');
         } else {
             // Decrypt data
             $result = Crypt::symmetricDecryptFileContent($data, $this->plainKey, $this->cipher);
         }
     }
     return $result;
 }
開發者ID:Combustible,項目名稱:core,代碼行數:30,代碼來源:stream.php


注:本文中的Crypt::isHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。