本文整理汇总了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;
}
示例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;
}