Message generation method and device, message analysis method and device, equipment and storage medium

By including compression and encryption algorithm identification information in the message header, the problem of low scalability of message compression and encryption in the prior art is solved, multi-algorithm support and information security are realized, and data transmission efficiency is improved.

CN119094622APending Publication Date: 2024-12-06深圳开鸿数字产业发展有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411065759.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

In the prior art, the fixed default compression encryption method limits the scalability of packet compression encryption, resulting in only limited compression algorithms and encryption algorithm types, reducing the flexibility and efficiency of data transmission.

Method used

By including the identification information of the compression algorithm and encryption algorithm in the message header, the target message is generated, so that the destination can restore the original message using the corresponding decompression and decryption algorithm based on the received identification information, supporting a variety of compression and encryption algorithms. Use of

Benefits of technology

It realizes the scalability of packets, allows the use of a variety of compression and encryption algorithms, improves the flexibility and efficiency of data transmission, and ensures information security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119094622A_ABST
    Figure CN119094622A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of message processing, in particular to a message generation method and device, a message analysis method and device, equipment and a storage medium. According to the method, firstly, an original message is compressed and encrypted to generate a compressed and encrypted message, a compression algorithm is placed in a message header in a mode of compressing identification information, an encryption algorithm is also placed in the message header in a mode of encrypting the identification information, and the compressed and encrypted message and the message header are spliced; and the target message generated after splicing is sent to the destination end, so that the destination end obtains the compression algorithm and the encryption algorithm while receiving the compressed and encrypted message, and the destination end can restore the received compressed and encrypted message into the original message by using the compression algorithm and the encryption algorithm. As the message header in the target message can carry the compression identification information and the encryption identification information, the method is allowed to adopt a plurality of compression algorithms and encryption algorithms, so that the compression and encryption algorithms have expandability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of message processing, and in particular to a message generating method, parsing method, device, equipment and storage medium. Background Art

[0002] The IoT system includes the cloud (the cloud is also the destination) and edge devices. The edge devices send data to the cloud in the form of messages to realize data interaction between the edge devices and the cloud. Before sending the message to the cloud, the edge device must first process the message with a fixed default compression and encryption method (that is, a compression and encryption method agreed in advance and known by both the cloud and the edge device), and then send the message to the cloud. The cloud parses the received message according to the known compression and encryption method to restore the message. Since the fixed default compression and encryption method limits the types of compression algorithms and encryption algorithms that can be used, the scalability of message compression and encryption is reduced.

[0003] In summary, the existing technology reduces the scalability of message compression encryption.

[0004] Therefore, the prior art still needs to be improved and enhanced. Summary of the invention

[0005] In order to solve the above technical problems, the present invention provides a message generation method, parsing method, device, equipment and storage medium, which solves the problem that the prior art reduces the scalability of message compression and encryption.

[0006] To achieve the above object, the present invention adopts the following technical solutions:

[0007] In a first aspect, the present invention provides a message generation method, comprising:

[0008] Obtaining an original message, and processing the original message using a compression algorithm and an encryption algorithm to obtain a compressed encrypted message;

[0009] Determine compression identification information corresponding to the compression algorithm, determine encryption identification information corresponding to the encryption algorithm, and obtain a message header according to the compression identification information and the encryption identification information;

[0010] The compressed encrypted message and the message header are concatenated to obtain a target message, wherein the target message is used to be sent to a destination end, and the destination end is used to restore the target message to the original message.

[0011] In one implementation, the using a compression algorithm and an encryption algorithm to process the original message to obtain a compressed encrypted message includes:

[0012] Obtaining the type and length of the original message;

[0013] Determining a target compression algorithm among the compression algorithms according to the type and the length;

[0014] Compressing the original message using the target compression algorithm to obtain a compressed message;

[0015] The compressed message is encrypted using the encryption algorithm to obtain a compressed encrypted message.

[0016] In one implementation, obtaining a message header according to the compression identification information and the encryption identification information includes:

[0017] Determine the byte length occupied by the compressed identification information, and use the byte length as the first byte length, determine the byte length occupied by the encrypted identification information, and use the byte length as the second byte length;

[0018] Set the start identification information and the end identification information, count the byte length occupied by the start identification information, and use the byte length as the third byte length, count the byte length occupied by the end identification information, and use the byte length as the fourth byte length;

[0019] Obtaining a total byte length according to the first byte length, the second byte length, the third byte length, and the fourth byte length;

[0020] The start identification information, the total byte length, the compression identification information, the encryption identification information, and the end identification information are arranged in sequence to obtain a message header.

[0021] In one implementation, the step of concatenating the compressed encrypted message and the message header to obtain a target message includes:

[0022] The compressed encrypted message is spliced ​​behind the end identification information of the message header to obtain the target message.

[0023] In one implementation, the method further includes: setting a password for the target message, and storing a key corresponding to the password on the destination end.

[0024] In a second aspect, an embodiment of the present invention further provides a message parsing method, including:

[0025] Acquire a target message sent by a device, wherein the target message is a message generated based on the message generation method described above;

[0026] Parsing the target message to obtain a message header and a compressed encrypted message contained in the target message;

[0027] Parsing the message header to obtain compression identification information and encryption identification information contained in the message header;

[0028] Determine the compression algorithm corresponding to the compression identification information and the encryption algorithm corresponding to the encryption identification information;

[0029] Determine the decompression algorithm corresponding to the compression algorithm, and determine the decryption algorithm corresponding to the encryption algorithm;

[0030] Applying the decryption algorithm to the compressed encrypted message to obtain a decrypted compressed message;

[0031] A decompression algorithm is applied to the decrypted compressed message to obtain the original message.

[0032] In one implementation, the parsing of the target message to obtain a message header and a compressed encrypted message contained in the target message also includes:

[0033] A key is obtained, and the target message is verified using the key, and when the verification passes, the target message is parsed.

[0034] In a second aspect, an embodiment of the present invention further provides a message generating device, wherein the device comprises the following components:

[0035] The compression and encryption module is used to obtain the original message, process the original message using a compression algorithm and an encryption algorithm, and obtain a compressed and encrypted message;

[0036] A message header generation module, used to determine compression identification information corresponding to the compression algorithm, determine encryption identification information corresponding to the encryption algorithm, and obtain a message header according to the compression identification information and the encryption identification information;

[0037] The splicing module is used to splice the compressed encrypted message and the message header to obtain a target message, and the target message is used to send to a destination end, and the destination end is used to restore the target message to the original message.

[0038] In one implementation, the compression encryption module includes:

[0039] A transmission speed acquisition unit, used to acquire the type and length of the original message;

[0040] A compression algorithm setting unit, used for determining a target compression algorithm among the compression algorithms according to the type and the length;

[0041] A compression unit, configured to compress the original message using the target compression algorithm to obtain a compressed message;

[0042] The encryption unit is used to encrypt the compressed message using the encryption algorithm to obtain a compressed encrypted message.

[0043] In one implementation, the message header generation module includes:

[0044] a byte length calculation unit, used to determine a first byte length occupied by the compressed identification information, and to determine a second byte length occupied by the encrypted identification information;

[0045] an identification information setting unit, used for setting the start identification information and the end identification information, and counting the byte length occupied by the start identification information, and taking the byte length as the third byte length, and counting the byte length occupied by the end identification information, and taking the byte length as the fourth byte length;

[0046] a total byte length calculation unit, configured to obtain a total byte length according to the first byte length, the second byte length, the third byte length, and the fourth byte length;

[0047] The message header generation unit is used to arrange the start identification information, the total byte length, the compression identification information, the encryption identification information, and the end identification information in sequence to obtain a message header.

[0048] In one implementation, the splicing module includes:

[0049] The splicing unit is used to splice the compressed encrypted message behind the end identification information of the message header to obtain a target message.

[0050] In a third aspect, an embodiment of the present invention further provides a terminal device, wherein the terminal device includes a memory, a processor, and a message generation program stored in the memory and executable on the processor, and when the processor executes the message generation program, the steps of the message generation method described above are implemented;

[0051] Alternatively, the terminal device includes a memory, a processor, and a message parsing program stored in the memory and executable on the processor, and when the processor executes the message parsing program, the steps of the above-mentioned message parsing method are implemented.

[0052] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a message generation program is stored, and when the message generation program is executed by a processor, the steps of the message generation method described above are implemented;

[0053] Alternatively, a message parsing program is stored on the computer-readable storage medium, and when the message parsing program is executed by the processor, the steps of the message parsing method described above are implemented.

[0054] Beneficial effect: The present invention first compresses and encrypts the original message to generate a compressed encrypted message, and puts the compression algorithm in the message header in the form of compression identification information, and puts the encryption algorithm in the message header in the form of encryption identification information, and splices the compressed encrypted message and the message header, and sends the target message generated after splicing to the destination end, so that the destination end also learns the compression algorithm and the encryption algorithm while receiving the compressed encrypted message, so that the destination end can use the compression algorithm and the encryption algorithm to restore the received compressed encrypted message to the original message. From the above analysis, it can be seen that since the message header in the target message of the present invention can carry compression identification information and encryption identification information, even if the present invention adopts multiple compression algorithms and encryption algorithms, the destination end can restore the message according to the received compression algorithm and encryption algorithm, so that the compression and encryption algorithms of the present invention are scalable. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 It is the overall flow chart of the present invention;

[0056] Figure 2 A flow chart for generating a target message in an embodiment of the present invention;

[0057] Figure 3 This is a destination end parsing flow chart in an embodiment of the present invention;

[0058] Figure 4 A structural diagram of a message generating device provided by the present invention;

[0059] Figure 5 This is a block diagram of the internal structure principle of the terminal device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0060] The following is a clear and complete description of the technical solution of the present invention in combination with the embodiments and the accompanying drawings. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0061] Research has found that the IoT system includes the cloud (the cloud is also the destination) and edge devices. The edge devices send data to the cloud in the form of messages to achieve data interaction between the edge devices and the cloud. Before sending the message to the cloud, the edge device must first process the message with a fixed default compression and encryption method (that is, a compression and encryption method agreed in advance and known by both the cloud and the edge device), and then send the message to the cloud. The cloud parses the received message according to the known compression and encryption method to restore the message. Since the fixed default compression and encryption method limits the types of compression algorithms and encryption algorithms that can be used, the scalability of message compression and encryption is reduced.

[0062] In order to solve the above technical problems, the present invention provides a message generation method, parsing method, device, equipment and storage medium, which solves the problem that the prior art reduces the scalability of message compression and encryption. In specific implementation, the original message is first obtained, and the original message is processed by a compression algorithm and an encryption algorithm to obtain a compressed encrypted message; then the compression identification information corresponding to the compression algorithm is determined, the encryption identification information corresponding to the encryption algorithm is determined, and the message header is obtained based on the compression identification information and the encryption identification information; finally, the compressed encrypted message and the message header are spliced ​​to obtain a target message, and the target message is used to send to the destination end, and the destination end is used to restore the target message to the original message. The present invention can allow the use of multiple compression algorithms and encryption algorithms, so that the present invention has scalability.

[0063] For example, in the application scenario, a human vital index collection device uploads the collected human blood pressure, blood sugar and other human attribute parameters to the destination to save the human attribute parameters. The existing technology uses the following method to upload the human attribute parameters to the destination:

[0064] The compression algorithm and encryption algorithm are agreed upon in advance between the human vital index collection device and the destination end. The collection device processes the original message of the human attribute parameters according to the agreed compression algorithm and encryption algorithm to obtain a compressed encrypted message, and then splices the compressed encrypted message and the message header (the message header is only used to record the message header length, the device port number, and the message header start mark and end mark) together and sends them to the destination end. The destination end restores the compressed encrypted message according to the known agreed compression algorithm and encryption algorithm to obtain the original message. Since the collection device in the prior art can only process the original message according to the limited agreed compression algorithm and encryption algorithm, the destination end can restore the original message, thereby limiting the types of compression algorithms and encryption algorithms that can be used, which ultimately leads to the lack of scalability of the types of compression algorithms and encryption algorithms that can be used by the collection device.

[0065] The present invention uses the following method to upload human body attribute parameters to the destination:

[0066] The collection device uses a compression algorithm and an encryption algorithm to process the original message of the human attribute parameters to obtain a compressed encrypted message, and then adds the type of the compression algorithm and the type of the encryption algorithm in the message header in the form of an identifier, and then splices the message header and the compressed encrypted message together and sends them to the destination. The destination can know which decompression algorithm and decryption algorithm to use to restore the compressed encrypted message to the original message based on the compression identifier and encryption identifier in the message header. Since the collection device can inform the destination of the compression algorithm type and the encryption algorithm type in the form of an identifier, even if the collection device changes the compression algorithm type and the encryption algorithm type, the destination can restore the compressed encrypted message, thereby making the compression algorithm and the encryption algorithm of the present invention scalable.

[0067] Embodiment 1: This embodiment provides a message generation method. The message generation method of this embodiment can be applied to a terminal device. The terminal device can be a terminal product with a data processing function, such as a computer. In this embodiment, Figure 1 As shown in , the message generation method specifically includes the following steps:

[0068] S100, obtaining an original message, and processing the original message using a compression algorithm and an encryption algorithm to obtain a compressed encrypted message;

[0069] S200, determining compression identification information corresponding to the compression algorithm, determining encryption identification information corresponding to the encryption algorithm, and obtaining a message header according to the compression identification information and the encryption identification information;

[0070] S300, concatenating the compressed encrypted message and the message header to obtain a target message, wherein the target message is used to be sent to a destination end, and the destination end is used to restore the target message to the original message.

[0071] The application scenarios of this embodiment are as follows:

[0072] The acquisition device monitors the operating parameters of the industrial equipment, and processes the monitored operating parameters using compression algorithms and encryption algorithms to obtain compressed encrypted messages. At the same time, the acquisition device also adds the compression algorithm and encryption algorithm to the message header in the form of identifiers, and then splices the compressed encrypted message and the message header to obtain the target message, and sends the target message to the destination.

[0073] In this embodiment, step S100 includes the following specific steps S101, S102, S103, and S104:

[0074] S101, obtaining the type and length of the original message.

[0075] S102: Determine a target compression algorithm among the compression algorithms according to the type and the length.

[0076] S103: compress the original message using the target compression algorithm to obtain a compressed message.

[0077] That is, different algorithms are used according to different types and lengths of data. For example, Brotli algorithm is used for text data larger than 10M, DEFLATE algorithm is used for text data smaller than 10M, PNG compression algorithm is used for small pictures, and JPEG compression algorithm is used for large pictures.

[0078] This example can also determine the compression algorithm based on the required transmission speed between the device and the destination. That is, if there is a high real-time requirement between the device and the destination, that is, a high transmission speed is required between the two, then a compression algorithm with a relatively high degree of compression should be selected to compress the original message to the greatest extent, so as to minimize the memory occupied by the original message, thereby increasing the transmission speed.

[0079] If the real-time requirement between the device and the destination is not high, that is, there is no high requirement for the transmission speed between the two, then a compression algorithm with a relatively small compression degree can be selected to reduce the distortion of the original message.

[0080] In this embodiment, the compression algorithm includes LZSS algorithm, DEFLATE algorithm, LZMA algorithm and the like.

[0081] In this embodiment, the original message can also be compressed in the following manner:

[0082] The original message is compressed to obtain a compressed message, which includes retained data, compressed data and compression metadata. The compression metadata includes compression parameters and compression offset, wherein the compression parameters are the compression algorithm used to compress the data and the parameters used by the compression algorithm. The compression offset refers to the starting position of the compressed data, and the starting position is located after the retained data.

[0083] The reserved data in this embodiment can be displayed externally, that is, the reserved data can be known by other terminals except the device. The reserved data can be data quality and flow analysis to facilitate external monitoring equipment to monitor data quality.

[0084] S104: Encrypt the compressed message using the encryption algorithm to obtain a compressed encrypted message.

[0085] In this embodiment, the encryption algorithms include AES algorithm, DES algorithm, RSA algorithm, ECC algorithm and SM series algorithm.

[0086] In this embodiment, encryption can also be performed in the following manner:

[0087] A random sequence is set and the device model is encoded to obtain the encoded model. The compressed message is first encrypted according to the random sequence and the encoded model, and then the first encrypted message is second encrypted based on the destination model to obtain the final encrypted message.

[0088] like Figure 2 As shown, this embodiment is to compress first and then encrypt, which has the following technical effects:

[0089] If encryption is performed first, random characters will be generated, thereby reducing the compression effect. However, in this embodiment, compression is performed first and encryption is performed later, so random characters will not be generated, thereby maintaining both the encryption effect and the compression effect.

[0090] In this embodiment, step S200 includes the following specific steps S201, S202, S203, and S204:

[0091] S201, determine the byte length occupied by the compressed identification information, and use the byte length as the first byte length, determine the byte length occupied by the encrypted identification information, and use the byte length as the second byte length.

[0092] For example, if the compression algorithm is the eighth compression algorithm in the compression algorithm library, then the eighth compression algorithm corresponds to 1000 (binary encoding), and the compression identification information is 00011000. The fourth digit "1" from the front represents compression, and the fifth to eighth digits "1000" represent the use of the eighth compression algorithm. The first to third digits "000" are unused reserved fields. The byte length of the compression identification information 00011000 is 1 Byte, that is, the length of the first byte is 1 Byte.

[0093] If the compression algorithm is the 20th compression algorithm in the compression algorithm library, then the 20th compression algorithm corresponds to 00010100 (binary encoding form), plus the reserved field 0000000, then the compression identification information is 0000000100010100, that is, the length of the first byte is 2Byte.

[0094] Similarly, if the selected encryption algorithm is the second algorithm in the encryption algorithm database, the second algorithm corresponds to 0010, and the encryption identification information is 10010000. The first "1" represents encryption, the second to fifth "0010" represents the second encryption algorithm type, and the sixth to eighth "000" is an unused reserved field. The byte length occupied by the encryption identification information 10010000 is 1 Byte, that is, the second byte length is 1 Byte.

[0095] If the selected encryption algorithm is the 20th algorithm in the encryption algorithm database, the 20th algorithm corresponds to 00010100 (binary encoding), plus the reserved field 0000000, then the encryption identification information is 0000000100010100, that is, the second byte length is 2Byte.

[0096] In summary, the message header of this embodiment is provided with a reserved field, and the message header is provided with four characters for identifying the compression algorithm, that is, this embodiment supports up to 16 compression algorithms. The message header is also provided with four characters for identifying the encryption algorithm, that is, this embodiment supports up to 16 encryption algorithms. That is, this embodiment allows the use of any of the 16 compression algorithms to compress the original message, and the compression type can be informed to the destination end through the compression identifier of the message header. Similarly, this embodiment allows the use of any of the 16 encryption algorithms to encrypt the original message, and the encryption type can be informed to the destination end through the encryption identifier of the message header.

[0097] S202, set the start identification information and the end identification information, and count the byte length occupied by the start identification information, and use the byte length as the third byte length, count the byte length occupied by the end identification information, and use the byte length as the fourth byte length.

[0098] The start identification information of this embodiment is used to indicate the start position of the message header, and the end identification information is used to indicate the end position of the message header. The start and end (end is also the end) of the message header are identified by 1-byte fixed characters for program identification, that is, the third byte length and the fourth byte length of this embodiment are both fixed to 1 byte. The fixed character at the start is '$' (ASCII value is 36).

[0099] S203: Obtain a total byte length according to the first byte length, the second byte length, the third byte length, and the fourth byte length.

[0100] That is, the first byte length plus the second byte length plus the third byte length plus the fourth byte length to get the total byte length.

[0101] S204, arrange the start identification information, the total byte length, the compression identification information, the encryption identification information, and the end identification information in sequence to obtain a message header.

[0102] The structure of the message header is shown in Table 1. The compression identification information and encryption identification information are part of the message header content. The message header content also includes a message content check bit (1 Byte is used to represent the length of the check bit), which is used to check whether the compressed encrypted message meets the specification. The check bit is generated by CRC-8 calculation. That is, the entire message header includes the start identifier (whose length is 1 Byte), the message header length (that is, the length of the entire message header is represented by 1 Byte character length. For example, if the length of the entire message header is 6, then the character representation is 00000110, and the length of 00000110 is 1 Byte), the message header content and the end identifier (whose length is 1 Byte).

[0103] Table 1

[0104]

[0105] In this embodiment, step S300 includes the following specific steps: splicing the compressed encrypted message after the end identification information of the message header to obtain the target message.

[0106] Splicing means combining the message header and the compressed encrypted message into a whole target message, wherein the compressed encrypted message is located behind the message header.

[0107] In this embodiment, the device sets a password for the target message and sends the key of the password to the destination end. Setting the password and key has the following technical effects:

[0108] Since the header of the message sent to the destination carries the type of encryption algorithm and compression algorithm, if no password is set, other terminals can decompress and decrypt the compressed and encrypted message when they intercept the target message, thereby causing information leakage. However, the present embodiment sets a password and a key, so that only the destination specified by the device can decompress and decrypt, thereby ensuring information security.

[0109] Embodiment 2: This embodiment provides a message parsing method, including S401 to S407:

[0110] S401, obtaining a target message sent by a device.

[0111] The target message is a message generated based on the message generation method in the first embodiment.

[0112] S402, parse the target message to obtain a message header and a compressed encrypted message included in the target message.

[0113] The destination end performs this operation before parsing the target message. The destination end must first obtain the device sending key, and use the key to verify the target message through the verification password. When the verification is passed, the target message will be parsed.

[0114] S403: parse the message header to obtain compression identification information and encryption identification information contained in the message header.

[0115] S404: Determine a compression algorithm corresponding to the compression identification information and an encryption algorithm corresponding to the encryption identification information.

[0116] S405: Determine a decompression algorithm corresponding to the compression algorithm, and determine a decryption algorithm corresponding to the encryption algorithm.

[0117] First, locate the message header start identifier, then read the fourth byte after the message header start identifier, determine whether to compress and the type of compression algorithm based on the eight characters of the fourth byte, and infer the type of decompression algorithm required based on the type of compression algorithm, and use the decompression algorithm for decompression.

[0118] Similarly, read the fifth byte after the start identifier of the message header, determine whether to encrypt and the type of encryption algorithm based on the eight characters contained in the fifth byte, infer the type of decryption algorithm required based on the type of encryption algorithm, and use the decryption algorithm for decryption.

[0119] S406, applying the decryption algorithm to the compressed encrypted message to obtain a decrypted compressed message;

[0120] S407, applying a decompression algorithm to the decrypted compressed message to obtain the original message.

[0121] like Figure 3 As shown, the destination end must first parse the message header and verify it, and then determine whether it is an encrypted message based on the message header content. If it is, the corresponding algorithm and key are used to decrypt the message content according to the algorithm type carried in the message header. Finally, the message header content is determined to be a compressed message. If it is, the decrypted message content is decompressed using the corresponding algorithm according to the algorithm type carried in the message header to obtain the original message.

[0122] In summary, the present invention first compresses and encrypts the original message to generate a compressed encrypted message, and puts the compression algorithm in the message header in the form of compression identification information, and puts the encryption algorithm in the message header in the form of encryption identification information, and splices the compressed encrypted message and the message header, and sends the target message generated after splicing to the destination end, so that the destination end also learns the compression algorithm and the encryption algorithm while receiving the compressed encrypted message, so that the destination end can use the compression algorithm and the encryption algorithm to restore the received compressed encrypted message to the original message. From the above analysis, it can be seen that since the message header in the target message of the present invention can carry compression identification information and encryption identification information, even if the present invention adopts multiple compression algorithms and encryption algorithms, the destination end can restore the message according to the received compression algorithm and encryption algorithm, so that the compression and encryption algorithms of the present invention are scalable.

[0123] This embodiment also provides a message generating device, such as Figure 4 As shown, the device comprises the following components:

[0124] The compression and encryption module 01 is used to obtain the original message, and process the original message using a compression algorithm and an encryption algorithm to obtain a compressed and encrypted message;

[0125] The message header generation module 02 is used to determine the compression identification information corresponding to the compression algorithm, determine the encryption identification information corresponding to the encryption algorithm, and obtain the message header according to the compression identification information and the encryption identification information;

[0126] The splicing module 03 is used to splice the compressed encrypted message and the message header to obtain a target message, and the target message is used to be sent to a destination end, and the destination end is used to restore the target message to the original message.

[0127] Based on the above embodiments, the present invention further provides a terminal device, whose principle block diagram can be shown as follows: Figure 5 As shown. The terminal device includes a processor, a memory, a network interface, and a display screen connected through a system bus. Among them, the processor of the terminal device is used to provide computing and control capabilities. The memory of the terminal device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the terminal device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a message generation method is implemented. The display screen of the terminal device can be a liquid crystal display screen or an electronic ink display screen.

[0128] Those skilled in the art will understand that Figure 5The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the terminal device to which the scheme of the present invention is applied. The specific terminal device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0129] In one embodiment, a terminal device is provided. The terminal device includes a memory, a processor, and a message generation program stored in the memory and executable on the processor. When the processor executes the message generation program, the following operation instructions are implemented:

[0130] Obtaining an original message, and processing the original message using a compression algorithm and an encryption algorithm to obtain a compressed encrypted message;

[0131] Determine compression identification information corresponding to the compression algorithm, determine encryption identification information corresponding to the encryption algorithm, and obtain a message header according to the compression identification information and the encryption identification information;

[0132] The compressed encrypted message and the message header are concatenated to obtain a target message, wherein the target message is used to be sent to a destination end, and the destination end is used to restore the target message to the original message.

[0133] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0134] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A message generation method, It is characterized in that include: Obtaining an original message, and processing the original message using a compression algorithm and an encryption algorithm to obtain a compressed encrypted message; Determine compression identification information corresponding to the compression algorithm, determine encryption identification information corresponding to the encryption algorithm, and obtain a message header according to the compression identification information and the encryption identification information; The compressed encrypted message and the message header are concatenated to obtain a target message, wherein the target message is used to be sent to a destination end, and the destination end is used to restore the target message to the original message.

2. The message generating method according to claim 1, It is characterized in that The step of using a compression algorithm and an encryption algorithm to process the original message to obtain a compressed encrypted message includes: Obtaining the type and length of the original message; Determining a target compression algorithm among the compression algorithms according to the type and the length; Compressing the original message using the target compression algorithm to obtain a compressed message; The compressed message is encrypted using the encryption algorithm to obtain a compressed encrypted message.

3. The message generating method according to claim 1, It is characterized in that The obtaining of the message header according to the compression identification information and the encryption identification information includes: Determine the byte length occupied by the compressed identification information, and use the byte length as the first byte length, determine the byte length occupied by the encrypted identification information, and use the byte length as the second byte length; Set the start identification information and the end identification information, count the byte length occupied by the start identification information, and use the byte length as the third byte length, count the byte length occupied by the end identification information, and use the byte length as the fourth byte length; Obtaining a total byte length according to the first byte length, the second byte length, the third byte length, and the fourth byte length; The start identification information, the total byte length, the compression identification information, the encryption identification information, and the end identification information are arranged in sequence to obtain a message header.

4. The message generating method according to claim 3, It is characterized in that The step of splicing the compressed encrypted message and the message header to obtain a target message includes: The compressed encrypted message is spliced ​​behind the end identification information of the message header to obtain the target message.

5. The message generation method according to any one of claims 1 to 4, It is characterized in that Also includes: A password is set for the target message, and a key corresponding to the password is stored on the destination end.

6. A message parsing method, It is characterized in that include: Acquire a target message sent by a device, wherein the target message is a message generated based on the message generation method according to claim 1; Parsing the target message to obtain a message header and a compressed encrypted message contained in the target message; Parsing the message header to obtain compression identification information and encryption identification information contained in the message header; Determine the compression algorithm corresponding to the compression identification information and the encryption algorithm corresponding to the encryption identification information; Determine the decompression algorithm corresponding to the compression algorithm, and determine the decryption algorithm corresponding to the encryption algorithm; Applying the decryption algorithm to the compressed encrypted message to obtain a decrypted compressed message; A decompression algorithm is applied to the decrypted compressed message to obtain the original message.

7. The message parsing method according to claim 6, It is characterized in that The step of parsing the target message to obtain a message header and a compressed encrypted message contained in the target message also includes: A key is obtained, and the target message is verified using the key, and when the verification passes, the target message is parsed.

8. A message generating device, It is characterized in that The device comprises the following components: The compression and encryption module is used to obtain the original message, process the original message using a compression algorithm and an encryption algorithm, and obtain a compressed and encrypted message; A message header generation module, used to determine compression identification information corresponding to the compression algorithm, determine encryption identification information corresponding to the encryption algorithm, and obtain a message header according to the compression identification information and the encryption identification information; The splicing module is used to splice the compressed encrypted message and the message header to obtain a target message, and the target message is used to send to a destination end, and the destination end is used to restore the target message to the original message.

9. A terminal device, It is characterized in that The terminal device includes a memory, a processor, and a message generation program stored in the memory and executable on the processor, and when the processor executes the message generation program, the steps of the message generation method according to any one of claims 1 to 5 are implemented; Alternatively, the terminal device includes a memory, a processor, and a message parsing program stored in the memory and executable on the processor, and when the processor executes the message parsing program, the steps of the message parsing method as described in any one of claims 6-7 are implemented.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a message generation program, and when the message generation program is executed by the processor, the steps of the message generation method according to any one of claims 1 to 5 are implemented; Alternatively, a message parsing program is stored on the computer-readable storage medium, and when the message parsing program is executed by the processor, the steps of the message parsing method according to any one of claims 6 to 7 are implemented.