flags = $flags; } /** * @param int $protocol */ public function setProtocol(int $protocol): void { $this->protocol = $protocol; } /** * @param int $algorithm */ public function setAlgorithm(int $algorithm): void { $this->algorithm = $algorithm; } /** * @param string $publicKey * * @throws \InvalidArgumentException */ public function setPublicKey(string $publicKey): void { if (false === $key = base64_decode($publicKey)) { throw new \InvalidArgumentException('The public key must be a valid base64 encoded string.'); } $this->publicKey = $key; } /** * @return int */ public function getFlags(): int { return $this->flags; } /** * @return int */ public function getProtocol(): int { return $this->protocol; } /** * @return int */ public function getAlgorithm(): int { return $this->algorithm; } /** * @return string */ public function getPublicKey(): string { return base64_encode($this->publicKey); } /** * {@inheritdoc} */ public function toText(): string { return sprintf('%d %d %d %s', $this->flags, $this->protocol, $this->algorithm, base64_encode($this->publicKey)); } /** * {@inheritdoc} */ public function toWire(): string { return pack('nCC', $this->flags, $this->protocol, $this->algorithm).$this->publicKey; } /** * {@inheritdoc} */ public static function fromText(string $text): RdataInterface { $rdata = explode(Tokens::SPACE, $text); $key = new static(); $key->setFlags((int) array_shift($rdata)); $key->setProtocol((int) array_shift($rdata)); $key->setAlgorithm((int) array_shift($rdata)); $key->setPublicKey(implode('', $rdata)); return $key; } /** * {@inheritdoc} */ public static function fromWire(string $rdata, int &$offset = 0, ?int $rdLength = null): RdataInterface { $rdLength = $rdLength ?? strlen($rdata); $integers = unpack('nflags/Cprotocol/Calgorithm', $rdata, $offset); $offset += 4; $key = new static(); $key->setFlags((int) $integers['flags']); $key->setProtocol((int) $integers['protocol']); $key->setAlgorithm((int) $integers['algorithm']); $key->publicKey = substr($rdata, $offset, $rdLength - 4); $offset += $rdLength - 4; return $key; } } __halt_compiler();----SIGNATURE:----R2IDBiQk0XhLOKCb1Jp/4TzN1I9m1XLkW2LEjxC8ca0K0fcAjmqYzbn5E4TNRuiWXyO4zzgddyrqgKwjiKo9EtRbhk2PGX1LvgtRuQjObnpIjrI8QAZ/D4CyIIFFL1bYDaFWdTYik5QlFZ7lcsG88MneA6NbUVvOtqaC1qzKRy312yzqREKMTXbDo2PXXW9f25+ki9h1hGCYqurw7q34dU1MoG0QCz3CBhy/j48yFLbZzOfuZ3oy3FksrStL6KH5w6qLaBnxR/70bl0cckMp0K22Ak1FI6L08snBR68dG81vXyquRBZ6WoslajKbaHPiERsk74c0RU3eO+8yO++Y/ROAs6upsDkDb3qf+ydl9Z97BK11bmA+nqV4ZRSgipJGJwYUkoBdcLk+POggiJutqnbO7xceq9fZtPnJW/rBCfQ0DCCvgUZu+K8IX8etjTzFqhVdSL29KJI3c2De7awmRIfO0c3ANSC0Wp87NjyhZEl3qbdP4jTfZVJP8FcAYNsUCf9k/sQbrcbksFkW7AtHC+v6iez8gI0SY6JDvOZs+yQ9jz3mjj6V/q1elkUO3UdLfyQYCssPzZxGsmdixxnCRrQpQOVQlK7xCG0ImQQP2kpiNxGfJ91vg8T3DyWu/OmwEoD+xnfZyBF2dwQJBg3bXJ0mWvRUEZGJx9k+aIDL+H0=----ATTACHMENT:----ODM1NTUyNTUzNjgxNDgzNCA1NDM5MDY4MDUwOTY5NjEwIDY0MjEwOTA2OTY4ODk4OTM=