/** * To binary * * @return string */ public function toBinary() { $binBody = $this->body->toBinary(); $this->header->setLenght(Util::binaryLength($binBody)); $binHeader = $this->header->toBinary(); $pad = $this->header->getPseudoPad($this->secret); if ($this->header->isEncrypted()) { $binData = $binHeader . ($binBody ^ $pad); } else { $binData = $binHeader . $binBody; } return $binData; }