/** * Encrypt a text message and send it to the threemaId * * @param string $threemaId * @param string $text * @throws \Threema\Core\Exception * @return \Threema\MsgApi\Commands\Results\SendE2EResult */ public final function sendTextMessage($threemaId, $text) { //random nonce first $nonce = $this->cryptTool->randomNonce(); //fetch the public key $receiverPublicKey = $this->fetchPublicKeyAndCheckCapability($threemaId, null); //create a box $textMessage = $this->cryptTool->encryptMessageText($text, $this->privateKey, $receiverPublicKey, $nonce); return $this->connection->sendE2E($threemaId, $nonce, $textMessage); }