version = $version; $this->keyid = substr($keyid,-16); $this->key_algorithm = $key_algorithm; $this->encrypted_data = $encrypted_data; } function read() { switch ($this->version = ord($this->read_byte())) { case 3: $rawkeyid = $this->read_bytes(8); $this->keyid = ''; // Store KeyID in Hex for ($i=0;$ikeyid .= sprintf('%02X',ord($rawkeyid{$i})); } $this->key_algorithm = ord($this->read_byte()); $this->encrypted_data = $this->input; break; default: throw new Exception("Unsupported AsymmetricSessionKeyPacket version: ".$this->version); } } function body() { $bytes = chr($this->version); for ($i=0;$ikeyid);$i+= 2) { $bytes .= chr(hexdec($this->keyid{$i}.$this->keyid{$i+1})); } $bytes .= chr($this->key_algorithm); $bytes .= $this->encrypted_data; return $bytes; } }