示例#1
0
文件: Reader.php 项目: sqon/sqon
 /**
  * Returns the size of the Sqon.
  *
  * @return integer The size of the Sqon.
  */
 private function getSize()
 {
     if (null === $this->size) {
         $position = $this->file->tell();
         $this->size = $this->file->size();
         $this->file->seek($position);
     }
     return $this->size;
 }
示例#2
0
文件: Signature.php 项目: sqon/sqon
 /**
  * Generates a new raw SHA-1 hash signature for a Sqon file manager.
  *
  * @param FileInterface $file   The Sqon file manager.
  * @param boolean       $signed The Sqon has a signature?
  *
  * @return string The new raw SHA-1 hash.
  */
 public function generate(FileInterface $file, $signed = false)
 {
     $context = hash_init('sha1');
     $bytes = 0;
     if ($signed) {
         $bytes = $file->size() - 20;
     }
     $file->seek(0);
     foreach ($file->iterate($bytes) as $buffer) {
         hash_update($context, $buffer);
     }
     return hash_final($context, true);
 }