This topic describes how to encrypt messages to improve the security of the network connections between clients and MNS.

Background information

You can use HTTP requests to access MNS from the Internet. For messages that contain sensitive information, you can improve the security of the network connections between clients and MNS by using the following two methods:

  • Use HTTPS endpoints of MNS.
  • Encrypt messages to prevent data theft.

Usage notes

  • Message encryption and decryption may affect the performance of the consumer client and receiver client.
  • Do not send unencrypted messages to a queue that exclusively receives encrypted messages.


This section describes a solution provided by MNS to encrypt messages.

  1. Encrypt messages on the sender client.
  2. Decrypt and consume messages on the receiver client.

Download the sample code.

  • The file provides the putMessage, popMessage, and deleteMessage API operations.
    • putMesssage: uses keys and an algorithm to encrypt messages before the messages are sent to MNS servers.
    • popMessage: decrypts messages that are received from MNS servers and returns the decrypted messages.
  • The file is used to generate the secretKey value that is used to encrypt and decrypt messages.
  • The file provides the sample code that is used to encrypt, decrypt, and delete messages.

For information about how to use the sample code, see ReadMe.txt.