public static function encryptWithAd(
        HiddenString $plaintext,
        EncryptionSecretKey $ourPrivateKey,
        EncryptionPublicKey $theirPublicKey,
        string $additionalData = '',
        $encoding = Halite::ENCODE_BASE64URLSAFE
    ): string {
        /** @var HiddenString $ss */
        $ss = self::getSharedSecret(
            $ourPrivateKey,
            $theirPublicKey
        );
        $sharedSecretKey = new EncryptionKey($ss);
        $ciphertext = SymmetricCrypto::encryptWithAd(
            $plaintext,
            $sharedSecretKey,
            $additionalData,
            $encoding
        );
        unset($sharedSecretKey);
        return $ciphertext;
    }
public static function encryptWithAd(
        HiddenString $plaintext,
        EncryptionSecretKey $ourPrivateKey,
        EncryptionPublicKey $theirPublicKey,
        string $additionalData = '',
        $encoding = Halite::ENCODE_BASE64URLSAFE
    ): string {
        /** @var HiddenString $ss */
        $ss = self::getSharedSecret(
            $ourPrivateKey,
            $theirPublicKey
        );
        $sharedSecretKey = new EncryptionKey($ss);
        $ciphertext = SymmetricCrypto::encryptWithAd(
            $plaintext,
            $sharedSecretKey,
            $additionalData,
            $encoding
        );
        unset($sharedSecretKey);
        return $ciphertext;
    }
public static function encryptWithAd ( HiddenString $ plaintext , EncryptionSecretKey $ ourPrivateKey , EncryptionPublicKey $ theirPublicKey , string $ additionalData = '' , $ encoding = Halite :: ENCODE_BASE64URLSAFE ) : string { /** @var HiddenString $ss */ $ ss = self :: getSharedSecret ( $ ourPrivateKey , $ theirPublicKey ) ; $ sharedSecretKey = new EncryptionKey ( $ ss ) ; $ ciphertext = SymmetricCrypto :: encryptWithAd ( $ plaintext , $ sharedSecretKey , $ additionalData , $ encoding ) ; unset ( $ sharedSecretKey ) ; return $ ciphertext ; }
Encrypt with additional associated data.

@param HiddenString $plaintext
@param EncryptionSecretKey $ourPrivateKey
@param EncryptionPublicKey $theirPublicKey
@param string $additionalData
@param string|bool $encoding
@return string

@throws CannotPerformOperation
@throws InvalidKey
@throws InvalidMessage
@throws InvalidDigestLength
@throws InvalidType
@throws \TypeError
Encrypt with additional associated data .