plaintext = $plaintext; $this->key = $key; $this->initializationVector = $initializationVector; $this->aad = $aad; $this->tagLength = $tagLength; $this->keySize = $keySize; // unsetting the property forces the first access to go through // __get(). unset($this->stream); } public function getOpenSslName() { return "aes-{$this->keySize}-gcm"; } /** * Same as static method and retained for backwards compatibility * * @return string */ public function getAesName() { return self::getStaticAesName(); } public function getCurrentIv() { return $this->initializationVector; } public function createStream() { if (\version_compare(\PHP_VERSION, '7.1', '<')) { return Psr7\Utils::streamFor(AesGcm::encrypt((string) $this->plaintext, $this->initializationVector, new Key($this->key), $this->aad, $this->tag, $this->keySize)); } else { return Psr7\Utils::streamFor(\openssl_encrypt((string) $this->plaintext, $this->getOpenSslName(), $this->key, \OPENSSL_RAW_DATA, $this->initializationVector, $this->tag, $this->aad, $this->tagLength)); } } /** * @return string */ public function getTag() { return $this->tag; } public function isWritable() : bool { return \false; } }