/**
  * Constructor
  *
  * @param   io.archive.zip.ZipArchiveWriter $writer
  * @param   io.archive.zip.ZipFileEntry $file
  * @param   string $name
  */
 public function __construct(ZipArchiveWriter $writer, ZipFileEntry $file, $name)
 {
     $this->writer = $writer;
     $this->file = $file;
     $this->name = $name;
     $this->data = null;
     $this->md = CRC32::digest();
 }
 /**
  * Constructor
  *
  * @param   io.streams.OutputStream out
  * @param   int level default 6
  * @throws  lang.IllegalArgumentException if the level is not between 0 and 9
  */
 public function __construct(OutputStream $out, $level = 6)
 {
     if ($level < 0 || $level > 9) {
         throw new \lang\IllegalArgumentException('Level ' . $level . ' out of range [0..9]');
     }
     // Write GZIP format header:
     // * ID1, ID2 (Identification, \x1F, \x8B)
     // * CM       (Compression Method, 8 = deflate)
     // * FLG      (Flags, use 0)
     // * MTIME    (Modification time, Un*x timestamp)
     // * XFL      (Extra flags, 2 = compressor used maximum compression)
     // * OS       (Operating system, 255 = unknown)
     $out->write(pack('CCCCVCC', 0x1f, 0x8b, 8, 0, time(), 2, 255));
     // Now, convert stream to file handle and append deflating filter
     $this->out = Streams::writeableFd($out);
     if (!($this->filter = stream_filter_append($this->out, 'zlib.deflate', STREAM_FILTER_WRITE, $level))) {
         fclose($this->out);
         $this->out = null;
         throw new \io\IOException('Could not append stream filter');
     }
     $this->md = CRC32::digest();
 }
Example #3
0
 /**
  * Prepare data to be sent
  *
  * @param   org.nagios.nsca.NscaMessage $message
  * @return  string
  */
 public function prepare(NscaMessage $message)
 {
     // Calculate CRC32 checksum, then build the final packet with the sig
     // and encrypt it using defined crypt method
     return $this->encrypt($this->pack(CRC32::fromString($this->pack(0, $message))->asInt32(), $message));
 }
 /**
  * Returns a checksum for a given input string
  *
  * @param   string data
  * @return  security.checksum.Checksum
  */
 protected function checksumOf($data)
 {
     return CRC32::fromString($data)->getValue();
 }