Smack API - 如何加密消息

时间:2014-06-12 08:11:16

标签: java encryption xmpp smack

我有这个ConnectionConfiguration

ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration(host, port);
connectionConfiguration.setCompressionEnabled(false);
connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
connectionConfiguration.setSASLAuthenticationEnabled(true);
connectionConfiguration.setDebuggerEnabled(true);
connectionConfiguration.setTruststorePath(TRUST_STORE_PATH);
connectionConfiguration.setTruststorePassword("changeit");

然后我连接

connection = new XMPPConnection(connectionConfiguration);

然后发送消息

Message msg = new Message(to, Message.Type.chat);
msg.setBody(text);
connection.sendPacket(msg);

我应该更改哪些内容来加密邮件?我需要这样的东西:

key = connection.generateEncryptionKeys()

msg.encrypt(key)

我正在使用Smack库。

0 个答案:

没有答案