/** * @param string $secret Secret or path to a file with secret */ public function __construct($secret) { if (is_file($secret)) { Util::assertFileIsReadable($secret); $secret = file_get_contents($secret); } $this->secret = $secret; $this->ensureSupport(); }
/** * @param string $publicKey */ public function setPublicKey($publicKey) { $this->publicKey = $publicKey; // this is a file if (is_file($publicKey)) { Util::assertFileIsReadable($publicKey); $this->publicKeyRes = openssl_get_publickey('file://' . $publicKey); } else { $this->publicKeyRes = openssl_get_publickey($publicKey); } // verify if (!is_resource($this->publicKeyRes)) { throw new \InvalidArgumentException('The public key could not be loaded.'); } }