The invention relates to an
encryption method applied to a
MQTT-SN protocol, and relates to the field of communication. The method employs a harsh
algorithm and
ciphertext-policy attribute-based
encryption method, so that a publishing terminal, an agent
server and one or a plurality of subscription terminals can complete encrypted communication. The method herein includes the following steps: an agent
server verifying the identity of a publishing / subscription terminal, performing registration of the publishing / subscription terminal, and generating a
system common parameter; the publishing terminal encrypting a
plaintext load by using the
ciphertext-policy attribute-based
encryption method; the publishing terminal transmitting the encrypted load to the agent
server, the agent server forwarding the encrypted load to one or a plurality of subscription terminals; and the subscription terminal applying for a secrete key from the agent server, decrypting the encrypted load, obtaining a
plaintext. According to the invention, the method can implement identity
verification of a
MQTT-SN protocol publishing / subscription terminal,
data integrity verification, and data
confidentiality protection, and better addresses the safety issues faced by the
MQTT-SN protocol in terminals of
wireless sensor network applications.