[go: up one dir, main page]

CN108075879B - Data encryption and decryption method, device and system - Google Patents

Data encryption and decryption method, device and system Download PDF

Info

Publication number
CN108075879B
CN108075879B CN201610990502.2A CN201610990502A CN108075879B CN 108075879 B CN108075879 B CN 108075879B CN 201610990502 A CN201610990502 A CN 201610990502A CN 108075879 B CN108075879 B CN 108075879B
Authority
CN
China
Prior art keywords
data
binary
key
leaf node
information stored
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610990502.2A
Other languages
Chinese (zh)
Other versions
CN108075879A (en
Inventor
陈晓
周本文
王磊
张富军
李黎黎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
China Mobile Group Anhui Co Ltd
Original Assignee
China Mobile Group Anhui Co Ltd
China Mobile Communications Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Mobile Group Anhui Co Ltd, China Mobile Communications Corp filed Critical China Mobile Group Anhui Co Ltd
Priority to CN201610990502.2A priority Critical patent/CN108075879B/en
Publication of CN108075879A publication Critical patent/CN108075879A/en
Application granted granted Critical
Publication of CN108075879B publication Critical patent/CN108075879B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0618Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Storage Device Security (AREA)

Abstract

本发明公开了一种数据加密和解密的方法、装置及系统。该方法包括:生成用于对数据加密的二叉树;基于二叉树生成第一遍历序列和第二遍历序列;确定二叉树中至少一个叶子节点存储的信息作为密钥;基于至少一个叶子节点的二叉树编码生成密钥加密信息;将密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥,以及将待传输数据转换为二进制待传输数据;将二进制密钥和二进制待传输数据按照预设加密算法进行计算得到加密数据;向待传输数据的接收端发送第一遍历序列、第二遍历序列、密钥加密信息和加密数据。本发明公开的数据加密和解密的方法,能够提高数据传输的安全性。

Figure 201610990502

The invention discloses a method, device and system for data encryption and decryption. The method includes: generating a binary tree for encrypting data; generating a first traversal sequence and a second traversal sequence based on the binary tree; determining information stored by at least one leaf node in the binary tree as a key; key encryption information; convert the information stored in each leaf node in the key into binary to obtain a binary key, and convert the data to be transmitted into binary data to be transmitted; the binary key and the binary data to be transmitted are performed according to the preset encryption algorithm The encrypted data is obtained by calculation; the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data are sent to the receiving end of the data to be transmitted. The data encryption and decryption method disclosed by the invention can improve the security of data transmission.

Figure 201610990502

Description

一种数据加密和解密的方法、装置及系统A method, device and system for data encryption and decryption

技术领域technical field

本发明属于通信技术领域,尤其涉及一种数据加密和解密的方法、装置及系统。The invention belongs to the field of communication technologies, and in particular relates to a method, device and system for data encryption and decryption.

背景技术Background technique

随着互联网技术的发展,越来越多的信息数据通过网络进行传输,如何保证数据传输安全性问题日益突出。目前人们在数据传输时,通常对传输的数据进行加密,以此来保证数据传输的安全性。现有数据加密算法有很多种,其中常用的一种数据加密算法为基于二叉树的加密算法。现有技术在运用基于二叉树的加密算法时,基于要加密的数据构造二叉树,使数据的内容存储二叉树的叶子节点上,由此将明文数据转化为密文数据,密文数据的形成是由二叉树的结构决定的,然后将生成的二叉树信息传输给接收端。由于现有技术中明文数据存储在生成的二叉树,传输的二叉树信息中势必包含全部或部分明文数据,这就使加密数据很容易被破解,降低了数据传输的安全性。With the development of Internet technology, more and more information and data are transmitted through the network, and the problem of how to ensure the security of data transmission has become increasingly prominent. At present, when people transmit data, they usually encrypt the transmitted data to ensure the security of data transmission. There are many kinds of existing data encryption algorithms, and a commonly used data encryption algorithm is a binary tree-based encryption algorithm. When the prior art uses the encryption algorithm based on the binary tree, the binary tree is constructed based on the data to be encrypted, and the content of the data is stored on the leaf nodes of the binary tree, thereby converting the plaintext data into ciphertext data, and the formation of the ciphertext data is formed by the binary tree. The structure is determined, and then the generated binary tree information is transmitted to the receiving end. Since plaintext data is stored in the generated binary tree in the prior art, the transmitted binary tree information must contain all or part of plaintext data, which makes encrypted data easy to be cracked and reduces the security of data transmission.

发明内容SUMMARY OF THE INVENTION

本发明实施例提供了一种数据加密和解密的方法、装置及系统,能够解决传输用于加密明文数据二叉树信息中包含了全部或部分明文数据,导致加密数据很容易被破解,降低了数据传输的安全性的问题。The embodiments of the present invention provide a method, device and system for data encryption and decryption, which can solve the problem that the binary tree information used for encrypting plaintext data contains all or part of the plaintext data, which makes the encrypted data easy to be cracked and reduces data transmission. security issues.

第一方面,本发明提供了一种数据加密的方法,包括:In a first aspect, the present invention provides a data encryption method, comprising:

生成用于对数据加密的二叉树;Generate a binary tree for encrypting data;

基于二叉树生成第一遍历序列和第二遍历序列,其中,通过第一遍历序列和第二遍历序列能够还原二叉树;generating a first traversal sequence and a second traversal sequence based on the binary tree, wherein the binary tree can be restored through the first traversal sequence and the second traversal sequence;

确定二叉树中至少一个叶子节点存储的信息作为密钥;Determine the information stored in at least one leaf node in the binary tree as the key;

基于至少一个叶子节点的二叉树编码生成密钥加密信息;Generate key encryption information based on binary tree encoding of at least one leaf node;

将密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥,以及将待传输数据转换为二进制待传输数据;Convert the information stored in each leaf node in the key into binary to obtain a binary key, and convert the data to be transmitted into binary data to be transmitted;

将二进制密钥和二进制待传输数据按照预设加密算法进行计算得到加密数据;Calculate the binary key and the binary data to be transmitted according to the preset encryption algorithm to obtain encrypted data;

向待传输数据的接收端发送第一遍历序列、第二遍历序列、密钥加密信息和加密数据。Send the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data to the receiving end of the data to be transmitted.

结合第一方面,在第一方面的第一种实施方式中,在所述向所述待传输数据的接收端发送所述第一遍历序列、所述第二遍历序列、所述密钥加密信息和所述加密数据之前,所述方法还包括:With reference to the first aspect, in a first implementation manner of the first aspect, the first traversal sequence, the second traversal sequence, and the key encryption information are sent to the receiving end of the data to be transmitted. and before the encrypted data, the method further includes:

生成包括第一数据包和第二数据包的至少两个不同的数据包,所述至少两个不同的数据包携带所述密钥加密信息和所述加密数据,且所述第一数据包包括所述第一遍历序列、所述第二数据包包括所述第二遍历序列;generating at least two different data packets including a first data packet and a second data packet, the at least two different data packets carrying the key encryption information and the encrypted data, and the first data packet including the first traversal sequence and the second data packet include the second traversal sequence;

所述向所述待传输数据的接收端发送所述第一遍历序列、所述第二遍历序列、所述密钥加密信息和所述加密数据包括:The sending of the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data to the receiving end of the data to be transmitted includes:

向所述接收端发送所述至少两个不同的数据包,其中分别发送所述第一数据包和所述第二数据包。The at least two different data packets are sent to the receiving end, wherein the first data packet and the second data packet are sent respectively.

结合第一方面,在第一方面的第二种实施方式中,基于所述至少一个叶子节点的二叉树编码生成密钥加密信息包括:With reference to the first aspect, in a second implementation manner of the first aspect, generating key encryption information based on binary tree encoding of the at least one leaf node includes:

基于所述至少一个叶子节点存储的信息的排列顺序对所述至少一个叶子节点的二叉树编码进行排列得到所述密钥加密信息。The key encryption information is obtained by arranging the binary tree codes of the at least one leaf node based on the arrangement order of the information stored in the at least one leaf node.

结合第一方面,在第一方面的第三种实施方式中,所述密钥中每个叶子节点存储的信息的排列顺序与所述二进制密钥中每个叶子节点存储的信息排序相同;With reference to the first aspect, in a third implementation manner of the first aspect, the order of the information stored in each leaf node in the key is the same as the order of information stored in each leaf node in the binary key;

所述将所述二进制密钥和所述二进制待传输数据按照预设加密算法进行计算得到加密数据包括:The encrypted data obtained by calculating the binary key and the binary data to be transmitted according to a preset encryption algorithm includes:

将所述二进制待传输数据根据所述二进制密钥中每个叶子节点存储的信息的排列顺序与所述二进制密钥中每个叶子节点存储的信息依次按照预设加密算法进行计算得到所述加密数据。The encryption is obtained by calculating the binary data to be transmitted according to the arrangement order of the information stored in each leaf node in the binary key and the information stored in each leaf node in the binary key according to a preset encryption algorithm. data.

结合第一方面或第一方面的任一种实施方式,在第一方面的第四种实施方式中,所述预设加密算法包括异或算法。With reference to the first aspect or any implementation manner of the first aspect, in a fourth implementation manner of the first aspect, the preset encryption algorithm includes an exclusive OR algorithm.

第二方面,本发明提供了一种数据解密的方法,包括:In a second aspect, the present invention provides a method for data decryption, comprising:

接收待传输数据的发送端发送的第一遍历序列、第二遍历序列、密钥加密信息和加密数据;Receive the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data sent by the sender of the data to be transmitted;

基于第一遍历序列和第二遍历序列还原得出二叉树;The binary tree is obtained by restoring based on the first traversal sequence and the second traversal sequence;

基于还原的二叉树和密钥加密信息确定包括二叉树中至少一个叶子节点存储的信息的密钥;Determine a key including information stored by at least one leaf node in the binary tree based on the restored binary tree and the key encryption information;

将密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥;Convert the information stored in each leaf node in the key into binary to obtain a binary key;

将二进制密钥和加密数据按照预设解密算法进行计算得到解密后的二进制待传输数据,预设解密算法与发送端对待传输数据进行加密的预设加密算法相对应;Calculate the binary key and the encrypted data according to a preset decryption algorithm to obtain the decrypted binary data to be transmitted, and the preset decryption algorithm corresponds to the preset encryption algorithm used by the sender to encrypt the data to be transmitted;

将解密后的二进制待传输数据转换为待传输数据。Convert the decrypted binary data to be transmitted into data to be transmitted.

结合第二方面,在第二方面的第一种实施方式中,所述接收待传输数据的发送端发送的第一遍历序列、第二遍历序列、密钥信息和加密数据包括:With reference to the second aspect, in a first implementation manner of the second aspect, the first traversal sequence, the second traversal sequence, the key information, and the encrypted data sent by the sending end that receives the data to be transmitted include:

接收所述发送端发送的包括第一数据包和第二数据包的至少两个不同的数据包,其中,所述至少两个不同的数据包携带所述密钥加密信息和所述加密数据,且所述第一数据包包括第一遍历序列,所述第二数据包包括所述第二遍历序列,所述第一数据包和所述第二数据包为所述发送端分别发送的。receiving at least two different data packets including a first data packet and a second data packet sent by the sending end, wherein the at least two different data packets carry the key encryption information and the encrypted data, In addition, the first data packet includes a first traversal sequence, the second data packet includes the second traversal sequence, and the first data packet and the second data packet are respectively sent by the sender.

结合第二方面,在第二方面的第二种实施方式中,所述基于还原的二叉树和所述密钥加密信息确定包括所述二叉树中至少一个叶子节点存储的信息的密钥包括:With reference to the second aspect, in a second implementation manner of the second aspect, determining the key including the information stored by at least one leaf node in the binary tree based on the restored binary tree and the key encryption information includes:

基于还原的二叉树和所述密钥加密信息确定所述密钥和所述密钥中每个叶子节点存储的信息的排列顺序。Based on the restored binary tree and the key encryption information, an arrangement order of the key and the information stored by each leaf node in the key is determined.

结合第二方面,在第二方面的第三种实施方式中,所述将所述二进制密钥和所述加密数据按照预设解密算法进行计算得到解密后的二进制待传输数据包括:In conjunction with the second aspect, in a third implementation manner of the second aspect, the decrypted binary data to be transmitted obtained by calculating the binary key and the encrypted data according to a preset decryption algorithm includes:

将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的排列顺序,依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据;或者,Calculate the encrypted data according to the arrangement order of the information stored in each leaf node in the binary key, and sequentially calculate the decrypted binary data with the information stored in each leaf node in the binary key according to a preset decryption algorithm. data; or,

将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的反向排列顺序,依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据。Calculate the encrypted data according to the reverse order of the information stored in each leaf node in the binary key, and sequentially calculate the encrypted data with the information stored in each leaf node in the binary key according to a preset decryption algorithm to obtain after decryption. binary data.

结合第二方面的第三种实施方式,在第二方面的第四种实施方式中,当将所述二进制密钥和所述加密数据按照预设解密算法进行计算得到解密后的二进制待传输数据的步骤采用将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的反向排列顺序依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据的执行方法时,所述预设解密算法包括异或运算。In combination with the third embodiment of the second aspect, in the fourth embodiment of the second aspect, when the binary key and the encrypted data are calculated according to the preset decryption algorithm, the decrypted binary data to be transmitted is obtained. The step is to calculate the encrypted data according to the reverse order of the information stored in each leaf node in the binary key and the information stored in each leaf node in the binary key according to a preset decryption algorithm. In the execution method of the decrypted binary data, the preset decryption algorithm includes an exclusive OR operation.

结合第二方面或第二方面的任一种实施方式,在第二方面的第五种实施方式中,所述预设解密算法与所述预设加密算法互为逆运算。With reference to the second aspect or any implementation manner of the second aspect, in a fifth implementation manner of the second aspect, the preset decryption algorithm and the preset encryption algorithm are mutually inverse operations.

第三方面,本发明提供了一种数据加密的装置,包括:In a third aspect, the present invention provides a data encryption device, comprising:

二叉树生成单元,用于生成用于对数据加密的二叉树;A binary tree generating unit for generating a binary tree for encrypting data;

序列生成单元,用于基于二叉树生成第一遍历序列和第二遍历序列,其中,通过第一遍历序列和第二遍历序列能够还原二叉树;a sequence generating unit, configured to generate a first traversal sequence and a second traversal sequence based on the binary tree, wherein the binary tree can be restored through the first traversal sequence and the second traversal sequence;

确定单元,用于确定二叉树中至少一个叶子节点存储的信息作为密钥;a determining unit, used for determining the information stored in at least one leaf node in the binary tree as a key;

密钥加密信息生成单元,用于基于至少一个叶子节点的二叉树编码生成密钥加密信息;a key encryption information generating unit, for generating key encryption information based on the binary tree encoding of at least one leaf node;

转换单元,用于将密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥,以及将待传输数据转换为二进制待传输数据;a conversion unit, used for converting the information stored in each leaf node in the key into binary to obtain a binary key, and converting the data to be transmitted into binary data to be transmitted;

计算单元,用于将二进制密钥和二进制待传输数据按照预设加密算法进行计算得到加密数据;a computing unit, configured to calculate the binary key and the binary data to be transmitted according to a preset encryption algorithm to obtain encrypted data;

发送单元,用于向待传输数据的接收端发送第一遍历序列、第二遍历序列、密钥加密信息和加密数据。The sending unit is configured to send the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data to the receiving end of the data to be transmitted.

结合第三方面,在第三方面的第一种实施方式中,还包括:In conjunction with the third aspect, in the first implementation manner of the third aspect, it also includes:

数据包生成单元,用于生成包括第一数据包和第二数据包的至少两个不同的数据包,所述至少两个不同的数据包携带所述密钥加密信息和所述加密数据,且所述第一数据包包括第一遍历序列,所述第二数据包包括所述第二遍历序列;a data packet generating unit configured to generate at least two different data packets including a first data packet and a second data packet, the at least two different data packets carrying the key encryption information and the encrypted data, and the first data packet includes a first traversal sequence, and the second data packet includes the second traversal sequence;

所述发送单元具体用于向所述接收端发送所述至少两个不同的数据包,其中分别发送所述第一数据包和所述第二数据包。The sending unit is specifically configured to send the at least two different data packets to the receiving end, wherein the first data packet and the second data packet are sent respectively.

结合第三方面,在第三方面的第二种实施方式中,所述密钥加密信息生成单元具体用于基于所述至少一个叶子节点存储的信息的排列顺序对所述至少一个叶子节点的二叉树编码进行排列得到所述密钥加密信息。With reference to the third aspect, in a second implementation manner of the third aspect, the key encryption information generation unit is specifically configured to perform a binary tree of the at least one leaf node based on the arrangement order of the information stored by the at least one leaf node The encoding is arranged to obtain the key encryption information.

结合第三方面,在第三方面的第三种实施方式中,所述密钥中每个叶子节点存储的信息的排列顺序与所述二进制密钥中每个叶子节点存储的信息排序相同;With reference to the third aspect, in a third embodiment of the third aspect, the order of the information stored in each leaf node in the key is the same as the order of information stored in each leaf node in the binary key;

所述计算单元具体用于将所述二进制待传输数据根据所述二进制密钥中每个叶子节点存储的信息的排列顺序与所述二进制密钥中每个叶子节点存储的信息依次按照预设加密算法进行计算得到所述加密数据。The computing unit is specifically configured to encrypt the binary data to be transmitted according to the arrangement order of the information stored by each leaf node in the binary key and the information stored by each leaf node in the binary key in sequence according to a preset sequence. The algorithm performs calculation to obtain the encrypted data.

结合第三方面或第三方面的任一种实施方式,在第三方面的第四种实施方式中,所述预设加密算法包括异或算法。With reference to the third aspect or any implementation manner of the third aspect, in a fourth implementation manner of the third aspect, the preset encryption algorithm includes an exclusive OR algorithm.

第四方面,本发明提供了一种数据解密的装置,包括:In a fourth aspect, the present invention provides a data decryption device, comprising:

接收单元,用于接收待传输数据的发送端发送的第一遍历序列、第二遍历序列、密钥加密信息和加密数据;a receiving unit, configured to receive the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data sent by the sending end of the data to be transmitted;

二叉树还原单元,用于基于第一遍历序列和第二遍历序列还原得出二叉树;The binary tree restoration unit is used to restore the binary tree based on the first traversal sequence and the second traversal sequence;

确定单元,用于基于还原的二叉树和密钥加密信息确定包括二叉树中至少一个叶子节点存储的信息的密钥;a determining unit for determining a key including information stored by at least one leaf node in the binary tree based on the restored binary tree and the key encryption information;

二进制转换单元,用于将密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥;The binary conversion unit is used to convert the information stored in each leaf node in the key into binary to obtain a binary key;

计算单元,用于将二进制密钥和加密数据按照预设解密算法进行计算得到解密后的二进制待传输数据,预设解密算法与发送端对待传输数据进行加密的预设加密算法相对应;a computing unit, configured to calculate the binary key and the encrypted data according to a preset decryption algorithm to obtain the decrypted binary data to be transmitted, the preset decryption algorithm corresponding to the preset encryption algorithm used by the sender to encrypt the data to be transmitted;

数据转换单元,用于将解密后的二进制待传输数据转换为待传输数据。The data conversion unit is used for converting the decrypted binary data to be transmitted into data to be transmitted.

结合第一方面,在第一方面的第一种实施方式中,所述接收单元具体用于接收所述发送端发送的包括第一数据包和第二数据包的至少两个不同的数据包,其中,所述至少两个不同的数据包携带所述密钥加密信息和所述加密数据,且所述第一数据包包括第一遍历序列,所述第二数据包包括所述第二遍历序列,所述第一数据包和所述第二数据包为所述发送端分别发送的。With reference to the first aspect, in a first implementation manner of the first aspect, the receiving unit is specifically configured to receive at least two different data packets including a first data packet and a second data packet sent by the transmitting end, Wherein, the at least two different data packets carry the key encryption information and the encrypted data, and the first data packet includes a first traversal sequence, and the second data packet includes the second traversal sequence , the first data packet and the second data packet are respectively sent by the sending end.

结合第一方面,在第一方面的第二种实施方式中,所述确定单元具体用于基于还原的二叉树和所述密钥加密信息确定所述密钥和所述密钥中每个叶子节点存储的信息的排列顺序。With reference to the first aspect, in a second implementation manner of the first aspect, the determining unit is specifically configured to determine the key and each leaf node in the key based on the restored binary tree and the key encryption information The order in which the stored information is arranged.

结合第一方面,在第一方面的第三种实施方式中,所述计算单元具体用于将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的排列顺序依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据,或者将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的反向排列顺序依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据。With reference to the first aspect, in a third implementation manner of the first aspect, the computing unit is specifically configured to combine the encrypted data with the encrypted data in sequence according to the arrangement order of information stored in each leaf node in the binary key. The information stored in each leaf node in the binary key is calculated according to a preset decryption algorithm to obtain the decrypted binary data, or the encrypted data is arranged according to the reverse order of the information stored in each leaf node in the binary key. Decrypted binary data is obtained by calculating sequentially with the information stored in each leaf node in the binary key according to a preset decryption algorithm.

结合第一方面的第三种实施方式,在第一方面的第四种实施方式中,当所述计算单元具体用于将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的反向排列顺序依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据时,所述预设解密算法包括异或运算。With reference to the third implementation manner of the first aspect, in the fourth implementation manner of the first aspect, when the computing unit is specifically configured to convert the encrypted data according to the information stored by each leaf node in the binary key When the decrypted binary data is obtained by calculating with the information stored in each leaf node in the binary key in reverse order according to a preset decryption algorithm, the preset decryption algorithm includes an exclusive OR operation.

结合第一方面或第一方面的任一种实施方式,在第一方面的第五种实施方式中,所述预设解密算法与所述预设加密算法互为逆运算。With reference to the first aspect or any implementation manner of the first aspect, in a fifth implementation manner of the first aspect, the preset decryption algorithm and the preset encryption algorithm are mutually inverse operations.

第五方面,本发明提供了一种数据加密和解密的系统,包括如第三方面所述的数据加密的装置和如第四方面所述的数据解密的装置。In a fifth aspect, the present invention provides a data encryption and decryption system, including the data encryption device as described in the third aspect and the data decryption device as described in the fourth aspect.

本发明提供一种数据加密和解密的方法、装置及系统,本发明中待传输数据的发送端生成用于对数据加密的二叉树,以及能够还原二叉树的第一遍历序列和第二遍历序列发送给待传输数据的接收端,接收端可以根据接收的两个遍历序列准确还原发送端生成的二叉树,保证对加密后待传输数据解密的准确性;发送端和接收端以二叉树中至少一个叶子节点存储的信息为密钥转换为二进制密钥后,发送端将二进制密钥与转换为二进制的待传输数据按照预设加密算法计算得到加密数据,接收端将二进制密钥与加密数据按照预设解密算法进行计算得到解密的二进制待传输数据,这样将二叉树与二进制运算相结合对待传输数据进行加解密,提高加解密的复杂度,使数据传输的安全性更高;发送端以二叉树中至少一个叶子节点存储的信息对待传输数据进行加密,但是向接收端发送的是基于至少一个叶子节点的二叉树编码生成密钥信息,接收端根据密钥信息可以确定出对待传输数据进行加密叶子节点存储的信息,这样在发送端和接收端之间并不会直接传输对待传输数据加解密的信息,而是传输对待传输数据加解密的信息进一步加密的密钥信息,从而提高对待传输数据加解密的信息传输的安全性,进而提高数据传输的安全性。并且本发明中在发送端和接收端进行数据传输时,不会涉及未加密的待传输数据的信息,避免了加密数据很容易被破解,降低数据传输安全性的问题。The present invention provides a data encryption and decryption method, device and system. In the present invention, the sending end of the data to be transmitted generates a binary tree for encrypting the data, and the first traversal sequence and the second traversal sequence capable of restoring the binary tree are sent to the For the receiving end of the data to be transmitted, the receiving end can accurately restore the binary tree generated by the transmitting end according to the two traversal sequences received, so as to ensure the accuracy of decrypting the encrypted data to be transmitted; the transmitting end and the receiving end are stored in at least one leaf node in the binary tree. After the information is converted into a binary key, the sender calculates the binary key and the data to be transmitted into binary according to the preset encryption algorithm to obtain encrypted data, and the receiver calculates the binary key and the encrypted data according to the preset decryption algorithm. Perform calculation to obtain the decrypted binary data to be transmitted. In this way, the binary tree and binary operations are combined to encrypt and decrypt the data to be transmitted, which improves the complexity of encryption and decryption and makes data transmission more secure; the sender uses at least one leaf node in the binary tree. The stored information is encrypted for the data to be transmitted, but the key information is generated based on the binary tree encoding of at least one leaf node sent to the receiving end, and the receiving end can determine the information stored in the leaf node to encrypt the data to be transmitted according to the key information. The sender and receiver do not directly transmit the encryption and decryption information of the data to be transmitted, but the key information that is further encrypted for the encryption and decryption of the data to be transmitted is transmitted, thereby improving the security of the information transmission of the encryption and decryption of the data to be transmitted. to improve the security of data transmission. Moreover, in the present invention, when data transmission is performed between the sending end and the receiving end, the information of the unencrypted data to be transmitted is not involved, which avoids the problem that the encrypted data is easily cracked and reduces the security of data transmission.

附图说明Description of drawings

为了更清楚地说明本发明实施例的技术方案,下面将对本发明实施例中所需要使用的附图作简单地介绍,显而易见地,下面所描述的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions of the embodiments of the present invention more clearly, the following briefly introduces the accompanying drawings that need to be used in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained from these drawings without any creative effort.

图1示出了根据本发明一实施例的数据加密的方法的示意性流程图;FIG. 1 shows a schematic flowchart of a method for data encryption according to an embodiment of the present invention;

图2示出了图1所示数据加密的方法中生成的二叉树的示意图;Fig. 2 shows the schematic diagram of the binary tree generated in the method for data encryption shown in Fig. 1;

图3示出了根据本发明又一实施例的数据加密的方法的示意性流程图;3 shows a schematic flowchart of a method for data encryption according to yet another embodiment of the present invention;

图4示出了根据本发明另一实施例的数据解密的方法的示意性流程图;4 shows a schematic flowchart of a method for decrypting data according to another embodiment of the present invention;

图5示出了根据本发明一实施例的数据加密的装置的示意性框图;5 shows a schematic block diagram of an apparatus for encrypting data according to an embodiment of the present invention;

图6示出了根据本发明又一实施例的数据加密的装置的示意性框图;6 shows a schematic block diagram of an apparatus for data encryption according to yet another embodiment of the present invention;

图7示出了根据本发明另一实施例的数据解密的装置的示意性框图;7 shows a schematic block diagram of an apparatus for decrypting data according to another embodiment of the present invention;

图8示出了根据本发明实施例的数据加密和解密的系统的示意性框图。FIG. 8 shows a schematic block diagram of a system for encrypting and decrypting data according to an embodiment of the present invention.

具体实施方式Detailed ways

为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

下面将详细描述本发明的各个方面的特征和示例性实施例。在下面的详细描述中,提出了许多具体细节,以便提供对本发明的全面理解。但是,对于本领域技术人员来说很明显的是,本发明可以在不需要这些具体细节中的一些细节的情况下实施。下面对实施例的描述仅仅是为了通过示出本发明的示例来提供对本发明的更好的理解。本发明决不限于下面所提出的任何具体配置和算法,而是在不脱离本发明的精神的前提下覆盖了元素、部件和算法的任何修改、替换和改进。在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本申请。Features and exemplary embodiments of various aspects of the invention are described in detail below. In the following detailed description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. However, it will be apparent to one skilled in the art that the present invention may be practiced without some of these specific details. The following description of the embodiments is only intended to provide a better understanding of the present invention by illustrating examples of the invention. The present invention is in no way limited to any specific configurations and algorithms set forth below, but covers any modification, substitution and improvement of elements, components and algorithms without departing from the spirit of the invention. The embodiments in this application and the features in the embodiments may be combined with each other without conflict. The present application will be described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.

本发明实施例适用于数据传输时,对待传输数据加密传输的场景。待传输数据的发送端通过本发明实施例中数据加密的方法对待传输数据进行加密后,待传输数据的接收端通过本发明实施例中数据解密的方法根据发送端发送的信息对加密数据进行解密,最终得出准确的待传输数据。The embodiments of the present invention are applicable to scenarios in which data to be transmitted is encrypted and transmitted during data transmission. After the transmitting end of the data to be transmitted encrypts the data to be transmitted by using the data encryption method in the embodiment of the present invention, the receiving end of the data to be transmitted decrypts the encrypted data according to the information sent by the transmitting end by using the data decryption method in the embodiment of the present invention. , and finally get the accurate data to be transmitted.

图1示出了根据本发明一实施例的数据加密的方法的示意性流程图。如图1所示,该方法可以用于待传输数据的发送端,包括以下步骤:S110,生成用于对数据加密的二叉树;S120,基于二叉树生成第一遍历序列和第二遍历序列;S130,确定二叉树中至少一个叶子节点存储的信息作为密钥;S140,基于至少一个叶子节点的二叉树编码生成密钥加密信息;S150,将所述密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥,以及将待传输数据转换为二进制待传输数据;S160,将二进制密钥和二进制待传输数据按照预设加密算法进行计算得到加密数据;S170,向待传输数据的接收端发送第一遍历序列、第二遍历序列、密钥加密信息和加密数据。FIG. 1 shows a schematic flowchart of a method for data encryption according to an embodiment of the present invention. As shown in Figure 1, the method can be used for the sending end of the data to be transmitted, and includes the following steps: S110, generating a binary tree for encrypting the data; S120, generating a first traversal sequence and a second traversal sequence based on the binary tree; S130, Determine the information stored by at least one leaf node in the binary tree as a key; S140, generate key encryption information based on the binary tree encoding of at least one leaf node; S150, convert the information stored in each leaf node in the key into binary to obtain binary key, and converting the data to be transmitted into binary data to be transmitted; S160, calculating the binary key and the binary data to be transmitted according to a preset encryption algorithm to obtain encrypted data; S170, sending a first traversal to the receiving end of the data to be transmitted Sequence, second traversal sequence, key encryption information and encrypted data.

在步骤S110中,发送端可以随机生成一个用于对数据加密的二叉树。例如,如图2所示,为本发明实施例为了对数据加密而生成的二叉树,二叉树采用哈夫曼编码huffman编码,对所有节点,若有左孩子,对其指向左孩子的分支编码为0,若其指向右孩子分支编码为1。In step S110, the sender may randomly generate a binary tree for encrypting data. For example, as shown in FIG. 2, it is a binary tree generated to encrypt data according to an embodiment of the present invention. The binary tree adopts Huffman coding huffman coding. For all nodes, if there is a left child, the branch that points to the left child is coded as 0 , coded as 1 if it points to the right child branch.

在步骤S120中,通过第一遍历序列和第二遍历序列能够还原唯一的一棵二叉树(为发送端生成的二叉树),即在接收端接收到第一遍历序列和第二遍历序列后,可以根据第一遍历序列和第二遍历序列得出发送端生成的二叉树。本领域技术人员可知二叉树通过不同的遍历方式得出不同的遍历序列,遍历方式包括:前序遍历序列、中序遍历序列、后序遍历序列和按层遍历序列,在二叉树的各种遍历序列中,前序遍历序列、中序遍历序列组合可以唯一确定出一个二叉树,后序遍历序列和按层遍历序列组合可以唯一确定出一个二叉树,所以本步骤中第一遍历序列和第二遍历序列可以为前序遍历序列、中序遍历序列,或者为后序遍历序列、按层序遍历序列。例如,如图2所示的二叉树,其中序遍历序列为DHBIEAFJCG、前序遍历序列为ABDHEICFJG,如果其他设备获得了图2所示的二叉树的中序遍历序列(DHBIEAFJCG)和前序遍历序列(ABDHEICFJG),则可以得出图2所示的二叉树。In step S120, a unique binary tree (a binary tree generated for the sender) can be restored through the first traversal sequence and the second traversal sequence, that is, after the receiver receives the first traversal sequence and the second traversal sequence, it can be The first traversal sequence and the second traversal sequence obtain the binary tree generated by the sender. Those skilled in the art know that a binary tree can obtain different traversal sequences through different traversal methods. The traversal methods include: pre-order traversal sequence, in-order traversal sequence, post-order traversal sequence and layer-by-layer traversal sequence. Among the various traversal sequences of binary trees , the combination of the pre-order traversal sequence and the in-order traversal sequence can uniquely determine a binary tree, and the combination of the post-order traversal sequence and the layer-by-layer traversal sequence can uniquely determine a binary tree, so the first traversal sequence and the second traversal sequence in this step can be Pre-order traversal sequence, in-order traversal sequence, or post-order traversal sequence, layer-order traversal sequence. For example, in the binary tree shown in Figure 2, where the in-order traversal sequence is DHBIEAFJCG and the pre-order traversal sequence is ABDHEICFJG, if other devices obtain the in-order traversal sequence (DHBIEAFJCG) and the pre-order traversal sequence (ABDHEICFJG) of the binary tree shown in Figure 2 ), the binary tree shown in Figure 2 can be obtained.

在步骤S130中,确定二叉树中至少一个叶子节点上存储的信息作为对待传输数据加密的密钥。例如,本发明实施例中选定图2所示二叉树中叶子节点GIJH存储的信息作为秘钥。In step S130, the information stored on at least one leaf node in the binary tree is determined as the key for encrypting the data to be transmitted. For example, in the embodiment of the present invention, the information stored in the leaf node GIJH in the binary tree shown in FIG. 2 is selected as the key.

在步骤S140中,基于步骤S130确定的至少一个叶子节点的二叉树编码生成密钥加密信息,即步骤130确定出至少一个叶子节点上存储的信息作为密钥后,这些确定出的叶子节点在二叉树上对应的二叉树编为密钥的密钥加密信息。由于对于二叉树的叶子节点,其二叉树编码是唯一的,所以在确定出二叉树和二叉树中叶子节点的二叉树编码后,可以唯一确定出叶子节点。例如,本发明实施例中选定图2所示二叉树中叶子节点GIJH存储的信息作为密钥,各叶子节点对应的二叉树编码分别:G的二叉树编码为11、I的二叉树编码为010、J的二叉树编码为101、H的二叉树编码为001,则密钥加密信息为(11 010 101 001)。In step S140, key encryption information is generated based on the binary tree encoding of at least one leaf node determined in step S130, that is, after step 130 determines the information stored on at least one leaf node as a key, these determined leaf nodes are on the binary tree. The corresponding binary tree is encoded as the key encryption information of the key. Since the binary tree code is unique for the leaf node of the binary tree, after the binary tree and the binary tree code of the leaf node in the binary tree are determined, the leaf node can be uniquely determined. For example, in the embodiment of the present invention, the information stored in the leaf node GIJH in the binary tree shown in FIG. 2 is selected as the key, and the binary tree codes corresponding to each leaf node are respectively: the binary tree code of G is 11, the binary tree code of I is 010, and the binary tree code of J is 010. The binary tree code is 101, and the binary tree code of H is 001, then the key encryption information is (11 010 101 001).

在步骤S150中,由于二进制的计算简单、操作方便,所以本步骤将密钥和待传输数据转化二进制再进行计算。本步骤中将密钥和待传输数据转为二进制的方法不做限定,例如可以通过相关函数进行转换,密钥GIJH转换为二进制后得出的二进制密钥为(01100111,01101001,01101010,01101000)。In step S150, since the binary calculation is simple and the operation is convenient, in this step, the key and the data to be transmitted are converted into binary and then calculated. In this step, the method of converting the key and the data to be transmitted into binary is not limited. For example, it can be converted through a correlation function. The binary key obtained after the key GIJH is converted into binary is (01100111, 01101001, 01101010, 01101000) .

在步骤S160中,预设加密算法为预先设置,具体的可以为异或算法等等,在此不做限定。In step S160, the preset encryption algorithm is preset, and the specific encryption algorithm may be an exclusive OR algorithm, etc., which is not limited herein.

本发明实施例中待传输数据的发送端生成用于对数据加密的二叉树,以及能够还原二叉树的第一遍历序列和第二遍历序列发送给待传输数据的接收端,使接收端可以根据接收的两个遍历序列准确还原发送端生成的二叉树,保证对加密后待传输数据解密的准确性;发送端以二叉树中至少一个叶子节点存储的信息为密钥,并转换为二进制后与转换为二进制的待传输数据按照预设加密算法进行计算得到加密数据,这样将二叉树与二进制运算相结合对待传输数据进行加解密,提高加解密的复杂度,使数据传输的安全性更高;发送端以二叉树中至少一个叶子节点存储的信息为密钥,但是向接收端发送的是基于密钥中各叶子节点的二叉树编码生成密钥加密信息,使接收端根据密钥加密信息可以确定出对待传输数据进行加密叶子节点存储的信息,这样在发送端和接收端之间并不会直接传输密钥,而是传输对密钥进一步加密的密钥加密信息,从而提高对待传输数据加解密的信息传输的安全性,进而提高数据传输的安全性。并且本发明中在发送端和接收端进行数据传输时,不会涉及未加密的待传输数据的信息,避免了加密数据很容易被破解,降低数据传输安全性的问题。In the embodiment of the present invention, the sender of the data to be transmitted generates a binary tree for encrypting the data, and the first traversal sequence and the second traversal sequence capable of restoring the binary tree are sent to the receiver of the to-be-transmitted data, so that the receiver can The two traversal sequences accurately restore the binary tree generated by the sender to ensure the accuracy of decrypting the encrypted data to be transmitted. The data to be transmitted is calculated according to the preset encryption algorithm to obtain encrypted data. In this way, the binary tree and binary operation are combined to encrypt and decrypt the data to be transmitted, which improves the complexity of encryption and decryption, and makes the data transmission more secure; the sender uses the binary tree in the binary tree. The information stored by at least one leaf node is a key, but the key encryption information is generated based on the binary tree encoding of each leaf node in the key, which is sent to the receiving end, so that the receiving end can determine according to the key encryption information to encrypt the data to be transmitted. The information stored by the leaf node, so that the key is not directly transmitted between the sender and the receiver, but the key encryption information that further encrypts the key is transmitted, thereby improving the security of information transmission for encryption and decryption of the data to be transmitted. , thereby improving the security of data transmission. Moreover, in the present invention, when data transmission is performed between the sending end and the receiving end, the information of the unencrypted data to be transmitted is not involved, which avoids the problem that the encrypted data is easily cracked and reduces the security of data transmission.

图3示出了根据本发明又一实施例的数据解密的方法的示意性流程图,图3所示实施例与图1所示实施例的区别在于,在方法中步骤S170之前,还可以执行步骤S180,生成包括第一数据包和第二数据包的至少两个不同的数据包;则步骤S170可以具体执行为:步骤S171,向接收端发送至少两个不同的数据包。Fig. 3 shows a schematic flowchart of a data decryption method according to another embodiment of the present invention. The difference between the embodiment shown in Fig. 3 and the embodiment shown in Fig. 1 is that before step S170 in the method, the method can also be executed Step S180, generating at least two different data packets including the first data packet and the second data packet; then step S170 may be specifically performed as: step S171, sending at least two different data packets to the receiving end.

其中,至少两个不同的数据包携带密钥加密信息和加密数据,且第一数据包包括第一遍历序列、第二数据包包括第二遍历序列。在步骤S180中发送端将要发送给接收端的第一遍历序列、第二遍历序列、密钥加密信息和加密数据生成包括第一数据包和第二数据包的至少两个数据包,其中,第一数据包包括第一遍历序列、第二数据包包括第二遍历序列,密钥加密信息与加密数据可以携带在至少两个数据包的任意一个数据包中。Wherein, at least two different data packets carry key encryption information and encrypted data, and the first data packet includes the first traversal sequence, and the second data packet includes the second traversal sequence. In step S180, the transmitting end generates at least two data packets including the first data packet and the second data packet from the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data to be sent to the receiving end, wherein the first data packet The data packet includes a first traversal sequence, the second data packet includes a second traversal sequence, and the key encryption information and encrypted data can be carried in any one of the at least two data packets.

在步骤S171中,分别发送第一数据包和第二数据包。发送端向接收端发送至少两个数据包时,需要分别发送第一数据包和第二数据包,这样避免第一遍历序列和第二遍历序列一同发送时,第一遍历序列和第二遍历序列同时被非法者截获,进而避免第一遍历序列和第二遍历序列同时传输时被截获还原出步骤S110中生成的二叉树,导致加密数据被破译,提高数据传输的安全性。In step S171, the first data packet and the second data packet are sent respectively. When the sending end sends at least two data packets to the receiving end, it needs to send the first data packet and the second data packet respectively, so as to avoid the first traversal sequence and the second traversal sequence when the first traversal sequence and the second traversal sequence are sent together. At the same time, it is intercepted by an illegal person, thereby preventing the first traversal sequence and the second traversal sequence from being intercepted and restoring the binary tree generated in step S110 when the first traversal sequence and the second traversal sequence are transmitted at the same time.

需要说明的是,发送端分别发送第一数据包和第二数据包的方式可以为同时但通过不同的通道发送,也可以发送端先后两次发送。在S171中发送的第一遍历序列和第二遍历序列也可以加密后再发送,进一步提高数据传输的安全性。It should be noted that the manner in which the sending end sends the first data packet and the second data packet respectively may be simultaneously but through different channels, or the sending end may send the first data packet and the second data packet twice in succession. The first traversal sequence and the second traversal sequence sent in S171 can also be encrypted before being sent, which further improves the security of data transmission.

可以理解的是,步骤S140可以具体执行为:步骤S141,基于至少一个叶子节点存储的信息的排列顺序对至少一个叶子节点的二叉树编码进行排列得到密钥加密信息。It can be understood that step S140 may be specifically executed as: step S141 , arranging the binary tree codes of at least one leaf node based on the arrangement order of information stored in at least one leaf node to obtain key encryption information.

其中,步骤S141中至少一个叶子节点存储的信息即为密钥中各叶子节点存储的信息,至少一个叶子节点的二叉树编码即为构成密钥的各叶子节点的二叉树编码。The information stored by at least one leaf node in step S141 is the information stored by each leaf node in the key, and the binary tree code of at least one leaf node is the binary tree code of each leaf node constituting the key.

需要说明的是,当密钥由多个叶子节点存储的信息构成时,不同的排列顺序会构成不同的密钥,如果密钥中各叶子节点存储的信息排列顺序不同,会导致在步骤S160对待加密数据进行加密时得到不同的结果,则需要密钥加密信息中各叶子节点的二叉树编码的排列顺序与密钥中各叶子节点存储的信息排列顺序一致,以便于发送端将密钥加密信息发送给接收端后,接收端可以根据密钥加密信息中各叶子节点的二叉树编码确定出密钥中各叶子节点存储的信息,以及根据密钥加密信息中各叶子节点的二叉树编码的排列顺序确定出密钥中各叶子节点存储的信息排列顺序,进而唯一确定出发送端生成的密钥,保证对加密数据解密的准确性。It should be noted that, when the key is composed of information stored by multiple leaf nodes, different order of arrangement will constitute different keys. Different results are obtained when the encrypted data is encrypted, and the arrangement order of the binary tree encoding of each leaf node in the key encryption information needs to be consistent with the arrangement order of the information stored in each leaf node in the key, so that the sender can send the key encryption information. After giving it to the receiving end, the receiving end can determine the information stored in each leaf node in the key according to the binary tree encoding of each leaf node in the key encryption information, and determine the information stored in each leaf node in the key encryption information according to the arrangement order of the binary tree encoding of each leaf node in the key encryption information. The order of the information stored in each leaf node in the key is used to uniquely determine the key generated by the sender to ensure the accuracy of decrypting encrypted data.

可以理解的是,在方法中,密钥中每个叶子节点存储的信息的排列顺序与二进制密钥中每个叶子节点存储的信息排序相同;步骤S160可以具体执行为步骤S161,将二进制待传输数据与二进制密钥中每个叶子节点存储的信息按照预设加密算法依次进行计算得到加密数据。It can be understood that, in the method, the order of the information stored in each leaf node in the key is the same as the order of the information stored in each leaf node in the binary key; step S160 can be specifically performed as step S161, where the binary to be transmitted is arranged in the same order. The information stored in each leaf node in the data and the binary key is sequentially calculated according to a preset encryption algorithm to obtain encrypted data.

其中,在步骤S150中将密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥后,步骤S160中可以将二进制密钥中每个叶子节点存储的信息作为一个整体与二进制待传输数据进行计算,也可以将二进制密钥中每个叶子节点存储的信息依次与二进制待传输数据进行计算。当将二进制待传输数据依次与二进制密钥中每个叶子节点存储的信息进行计算时,密钥中每个叶子节点存储的信息的排列顺序与二进制密钥中每个叶子节点存储的信息排序相同,然后执行步骤S161。如此在发送端执行步骤S170后,接收端可以根据发送端发送的信息确定出对待传输数据进行加密的密钥,进而根据密钥中每个叶子节点存储的信息的排列顺序确定出发送端在执行步骤S161时二进制待传输数据与二进制密钥中每个叶子节点存储的信息进行计算的顺序,以便于正确解密出待传输数据。Wherein, after converting the information stored in each leaf node in the key into binary to obtain a binary key in step S150, in step S160, the information stored in each leaf node in the binary key can be taken as a whole with the binary data to be transmitted For calculation, the information stored in each leaf node in the binary key can also be calculated sequentially with the binary data to be transmitted. When the binary data to be transmitted is calculated in turn with the information stored in each leaf node in the binary key, the order of the information stored in each leaf node in the key is the same as the order of information stored in each leaf node in the binary key , and then step S161 is executed. In this way, after the sending end performs step S170, the receiving end can determine the key for encrypting the data to be transmitted according to the information sent by the sending end, and then determine that the sending end is executing according to the arrangement order of the information stored in each leaf node in the key. In step S161, the order in which the binary data to be transmitted and the information stored in each leaf node in the binary key are calculated, so that the data to be transmitted can be decrypted correctly.

具体的,以步骤S150中得出的二进制密钥(01100111,01101001,01101010,01101000)与二进制待传输数据进行异或运算为例,步骤S161的计算过程为:(二进制待传输数据)⊕01100111⊕01101001⊕01101010⊕01101000。Specifically, taking the binary key (01100111, 01101001, 01101010, 01101000) obtained in step S150 for XOR operation with the binary data to be transmitted as an example, the calculation process of step S161 is: (binary data to be transmitted)⊕01100111⊕ 01101001⊕01101010⊕01101000.

需要说明得是,步骤S160中将二进制密钥中每个叶子节点存储的信息依次与二进制待传输数据进行计算,即进行了多次计算后得出加密数据,可以提高加密数据的复杂度,降低加密数据被破解的可能性,提高数据传输的安全性。It should be noted that, in step S160, the information stored in each leaf node in the binary key is sequentially calculated with the binary data to be transmitted, that is, the encrypted data is obtained after multiple calculations, which can improve the complexity of the encrypted data and reduce the The possibility of encrypted data being cracked increases the security of data transmission.

需要说明得是,在图1所示实施例中,在执行步骤S170之前,可以将加密数据转换为待传输数据的原始格式,然后在步骤S170中将转换为待传输数据的原始格式的加密数据发送给接收端。在执行步骤S110之前,发送端还可以向接收端发送通信请求,在接收到接收端的确认回复后执行步骤S110。It should be noted that, in the embodiment shown in FIG. 1 , before step S170 is performed, the encrypted data may be converted into the original format of the data to be transmitted, and then the encrypted data in the original format of the data to be transmitted is converted into the encrypted data in step S170 sent to the receiver. Before step S110 is performed, the sender may also send a communication request to the receiver, and step S110 is performed after receiving a confirmation reply from the receiver.

图4示出了根据本发明另一实施例的数据解密的方法的示意性流程图。如图4所示,该方法可以用于待传输数据的接收端,包括以下步骤:S210,接收待传输数据的发送端发送的第一遍历序列、第二遍历序列、密钥加密信息和加密数据;S220,基于第一遍历序列和第二遍历序列还原得出二叉树;S230,基于还原的二叉树和所述密钥加密信息确定包括所述二叉树中至少一个叶子节点存储的信息的密钥;S240,将所述密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥;S250,将所述二进制密钥和所述加密数据按照预设解密算法进行计算得到解密后的二进制待传输数据;S260,将所述解密后的二进制待传输数据转换为所述待传输数据。FIG. 4 shows a schematic flowchart of a method for decrypting data according to another embodiment of the present invention. As shown in Figure 4, the method can be used for the receiving end of the data to be transmitted, comprising the following steps: S210, receiving the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data sent by the transmitting end of the data to be transmitted S220, based on the first traversal sequence and the second traversal sequence to restore and obtain a binary tree; S230, based on the restored binary tree and the key encryption information, determine the key including the information stored by at least one leaf node in the binary tree; S240, Convert the information stored in each leaf node in the key into binary to obtain a binary key; S250, calculate the binary key and the encrypted data according to a preset decryption algorithm to obtain the decrypted binary data to be transmitted; S260: Convert the decrypted binary data to be transmitted into the data to be transmitted.

在步骤S210中,接收端接收步骤S170中发送端发送的第一遍历序列、第二遍历序列、密钥加密信息和加密数据。其中,第一遍历序列和第二遍历序列为发送端在通过步骤S110生成二叉树后再通过步骤S120得出的,密钥加密信息为发送端在通过步骤S140得出的,加密数据为发送端在通过步骤S160得出的。In step S210, the receiver receives the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data sent by the sender in step S170. Wherein, the first traversal sequence and the second traversal sequence are obtained by the sender through step S120 after generating the binary tree in step S110, the encryption key information is obtained by the sender through step S140, and the encrypted data is obtained by the sender in step S140. obtained through step S160.

在步骤S220中,由于发送端在通过步骤S120得出的第一遍历序列和第二遍历序列能够得到唯一的一棵二叉树,即发送端生成的二叉树,所以本步骤中接收端通过第一遍历序列和第二遍历序列还原二叉树,以便于基于二叉树确定密钥。In step S220, since the sender can obtain a unique binary tree from the first traversal sequence and the second traversal sequence obtained in step S120, that is, the binary tree generated by the sender, in this step, the receiver passes the first traversal sequence. and the second traversal sequence to restore the binary tree to facilitate key determination based on the binary tree.

在步骤S230中,由于密钥加密信息为二叉树中至少一个叶子节点的二叉树编码,所以基于密钥加密信息和步骤S210中得出的二叉树可以确定出密钥加密信息中包括了哪些叶子节点的二叉树编码,这些叶子节点构成密钥。In step S230, since the key encryption information is the binary tree encoding of at least one leaf node in the binary tree, the binary tree of which leaf nodes are included in the key encryption information can be determined based on the key encryption information and the binary tree obtained in step S210 encoding, these leaf nodes form the key.

在步骤S240中,在确定出密钥后,将密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥,通过二进制进行计算,计算过程简单、操作方便。In step S240, after the key is determined, the information stored in each leaf node in the key is converted into binary to obtain a binary key, and the binary key is calculated. The calculation process is simple and the operation is convenient.

在步骤S250中,预设解密算法与发送端对待传输数据进行加密的预设加密算法相对应。发送端在步骤S160中对二进制待传输数据和二进制密钥按照预设加密算法得出加密数据,本步骤中接收端需要根据二进制密钥和加密数据按照预设解密算法得出二进制待传输数据,所以预设加密算法与预设解密算法应当是相互对应的,这样才能保证接收端解密的出的二进制待传输数据是正确的。预设加密算法与预设解密算法应的对应关系可以包括多种,例如,预设解密算法与预设加密算法互为逆运算,预设解密算法与预设加密算法均为异或等相同的算法。In step S250, the preset decryption algorithm corresponds to the preset encryption algorithm used by the sender to encrypt the data to be transmitted. In step S160, the sender obtains the encrypted data according to the preset encryption algorithm according to the binary data to be transmitted and the binary key, and in this step, the receiver needs to obtain the binary data to be transmitted according to the binary key and the encrypted data according to the preset decryption algorithm, Therefore, the preset encryption algorithm and the preset decryption algorithm should correspond to each other, so as to ensure that the binary data to be transmitted decrypted by the receiving end is correct. The corresponding relationship between the preset encryption algorithm and the preset decryption algorithm may include multiple types. For example, the preset decryption algorithm and the preset encryption algorithm are inverse operations of each other, and the preset decryption algorithm and the preset encryption algorithm are the same as the XOR. algorithm.

在步骤S260中,由于步骤S250中得出的为二进制待传输数据,所以本步骤中将二进制待传输数据转换为待传输数据的原始格式,即得出发送端要向接收端传输的待传输数据。In step S260, since the binary data to be transmitted is obtained in step S250, the binary data to be transmitted is converted into the original format of the data to be transmitted in this step, that is, the data to be transmitted to be transmitted by the sender to the receiver is obtained. .

本发明实施例中由于发送端生成能够还原二叉树的第一遍历序列和第二遍历序列发送给接收端,所以接收端可以根据接收的两个遍历序列准确还原发送端生成的二叉树,保证对加密后待传输数据解密的准确性;接收端确定出包括至少一个叶子节点存储的信息的密钥,并转换为二进制后与解密数据按照预设解密算法进行计算得到解密的二进制待传输数据,这样将二叉树与二进制运算相结合对待传输数据进行加解密,提高解密的复杂度,使数据传输的安全性更高;接收端接收发送端发送的密钥加密信息,根据密钥加密信息可以确定出对待传输数据进行加密叶子节点存储的信息,这样在发送端和接收端之间并不会直接传输密钥,而是传输对密钥进一步加密的密钥加密信息,从而提高对待传输数据加解密的信息传输的安全性,进而提高数据传输的安全性。并且本发明中在发送端和接收端进行数据传输时,不会涉及未加密的待传输数据的信息,避免了加密数据很容易被破解,降低数据传输安全性的问题。In this embodiment of the present invention, since the sender generates the first traversal sequence and the second traversal sequence capable of restoring the binary tree and sends them to the receiver, the receiver can accurately restore the binary tree generated by the sender according to the two traversal sequences received, ensuring that the encrypted The accuracy of the decryption of the data to be transmitted; the receiving end determines the key including the information stored in at least one leaf node, converts it into binary, and calculates the decrypted data according to the preset decryption algorithm to obtain the decrypted binary data to be transmitted. Combined with binary operation to encrypt and decrypt the data to be transmitted, the complexity of decryption is increased, and the security of data transmission is higher; the receiving end receives the key encryption information sent by the sender, and can determine the data to be transmitted according to the key encryption information. Encrypt the information stored by the leaf node, so that the key is not directly transmitted between the sender and the receiver, but the key encryption information that further encrypts the key is transmitted, thereby improving the transmission efficiency of the information to be encrypted and decrypted. security, thereby improving the security of data transmission. Moreover, in the present invention, when the transmitting end and the receiving end perform data transmission, the information of the unencrypted data to be transmitted is not involved, which avoids the problem that the encrypted data is easily cracked and reduces the security of data transmission.

可以理解的是,在方法中,步骤S260可以具体执行为:步骤S261,接收发送端发送的包括第一数据包和第二数据包的至少两个不同的数据包。It can be understood that, in the method, step S260 may be specifically performed as: step S261, receiving at least two different data packets including the first data packet and the second data packet sent by the transmitting end.

在步骤S261中,至少两个不同的数据包携带密钥加密信息和加密数据,且第一数据包包括第一遍历序列,第二数据包包括第二遍历序列,第一数据包和第二数据包为发送端分别发送的。接收端接收发送端分别发送的第一数据包和第二数据包,这样避免第一遍历序列和第二遍历序列一同在发送端与接收端传输,可以避免第一遍历序列和第二遍历序列同时被非法者截获,进而避免第一遍历序列和第二遍历序列同时传输时被截获还原出步骤S110中生成的二叉树,导致加密数据被破译,提高数据传输的安全性。In step S261, at least two different data packets carry key encryption information and encrypted data, and the first data packet includes the first traversal sequence, the second data packet includes the second traversal sequence, the first data packet and the second data The packets are sent separately by the sender. The receiving end receives the first data packet and the second data packet respectively sent by the transmitting end, so that the first traversal sequence and the second traversing sequence are prevented from being transmitted together at the transmitting end and the receiving end, and the simultaneous transmission of the first traversing sequence and the second traversing sequence can be avoided. It is intercepted by an illegal person, thereby preventing the first traversal sequence and the second traversal sequence from being intercepted when transmitting at the same time and restoring the binary tree generated in step S110, resulting in the decryption of the encrypted data and improving the security of data transmission.

需要说明的是,接收端接收的密钥信息和加密数据可以通过第一信息或第二信息携带。在S261中接收的第一信息和第二信息也可以是加密的信息,进一步提高数据传输的安全性。It should be noted that the key information and encrypted data received by the receiving end may be carried by the first information or the second information. The first information and the second information received in S261 may also be encrypted information, which further improves the security of data transmission.

可以理解的是,步骤S230可以具体执行为:步骤S231,基于还原的二叉树和密钥加密信息确定密钥和密钥中每个叶子节点存储的信息的排列顺序。It can be understood that step S230 may be specifically executed as: step S231 , determining the key and the arrangement order of the information stored in each leaf node in the key based on the restored binary tree and the key encryption information.

其中,当密钥由多个叶子节点存储的信息构成时,不同的排列顺序会构成不同的密钥,如果密钥中各叶子节点存储的信息排列顺序不同,会导致在步骤S160对待加密数据进行加密时得到不同的结果,则密钥加密信息中各叶子节点的二叉树编码的排列顺序表示了密钥中各叶子节点存储的信息排列顺序,接收端需要根据密钥加密信息中各叶子节点的二叉树编码确定出密钥中各叶子节点存储的信息,以及根据密钥加密信息中各叶子节点的二叉树编码的排列顺序确定出密钥中各叶子节点存储的信息排列顺序,进而唯一确定出发送端生成的密钥,保证对加密数据解密的准确性。Wherein, when the key is composed of information stored by multiple leaf nodes, different arrangement orders will constitute different keys. If the arrangement order of the information stored in each leaf node in the key is different, it will cause the data to be encrypted to be processed in step S160. When different results are obtained during encryption, the arrangement order of the binary tree codes of each leaf node in the key encryption information represents the arrangement order of the information stored in each leaf node in the key, and the receiving end needs to encrypt the information according to the key. The encoding determines the information stored by each leaf node in the key, and determines the sequence of information stored in each leaf node in the key according to the order of the binary tree encoding of each leaf node in the key encryption information, and then uniquely determines that the sender generates key to ensure the accuracy of decrypting encrypted data.

例如,本发明实施例中得到如图2所示的二叉树,密钥加密信息为(11 010 101001),则可以得出构成密钥的叶子节点为G、I、J、H,密钥中各叶子节点的顺序为GIJH。For example, in the embodiment of the present invention, the binary tree shown in FIG. 2 is obtained, and the key encryption information is (11 010 101001), then it can be concluded that the leaf nodes constituting the key are G, I, J, and H. The order of leaf nodes is GIJH.

可以理解的是,在方法中,步骤S250可以具体执行为:步骤S251,将加密数据根据二进制密钥中每个叶子节点存储的信息的排列顺序依次与二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据,或者将加密数据根据二进制密钥中每个叶子节点存储的信息的反向排列顺序依次与二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据。It can be understood that, in the method, step S250 can be specifically executed as: step S251, the encrypted data is sequentially combined with the information stored in each leaf node in the binary key according to the arrangement order of the information stored in each leaf node in the binary key. The decrypted binary data is obtained by calculating according to the preset decryption algorithm, or the encrypted data is sequentially combined with the information stored in each leaf node in the binary key according to the reverse order of the information stored in each leaf node in the binary key according to the preset order. Suppose the decryption algorithm is calculated to obtain the decrypted binary data.

其中,步骤S160中可以将二进制密钥中每个叶子节点存储的信息作为一个整体与二进制待传输数据进行计算,也可以将二进制密钥中每个叶子节点存储的信息依次与二进制待传输数据进行计算。当将二进制待传输数据依次与二进制密钥中每个叶子节点存储的信息进行计算时,发送端执行步骤S170后,接收端可以根据发送端发送的信息确定出对待传输数据进行加密的密钥,进而根据密钥中每个叶子节点存储的信息的排列顺序确定出发送端在执行步骤S161时二进制待传输数据与二进制密钥中每个叶子节点存储的信息进行计算的顺序,然后在步骤S251中接收端根据二进制密钥中每个叶子节点存储的信息的排列顺序或者根据二进制密钥中每个叶子节点存储的信息的反向排列顺序依次与二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据,以便于正确解密出待传输数据。Wherein, in step S160, the information stored in each leaf node in the binary key can be calculated as a whole with the binary data to be transmitted, or the information stored in each leaf node in the binary key can be sequentially calculated with the binary data to be transmitted. calculate. When the binary data to be transmitted is sequentially calculated with the information stored in each leaf node in the binary key, after the sender performs step S170, the receiver can determine the key to encrypt the data to be transmitted according to the information sent by the sender, Then according to the arrangement order of the information stored in each leaf node in the key, determine the order in which the binary data to be transmitted and the information stored in each leaf node in the binary key are calculated by the sender when performing step S161, and then in step S251 According to the arrangement order of the information stored in each leaf node in the binary key, or according to the reverse order of the information stored in each leaf node in the binary key, the receiving end sequentially matches the information stored in each leaf node in the binary key according to the pre-determined order. It is assumed that the decryption algorithm performs calculation to obtain the decrypted binary data, so as to correctly decrypt the data to be transmitted.

需要说明的是,当步骤S250采用步骤S251中将加密数据根据二进制密钥中每个叶子节点存储的信息的反向排列顺序依次与二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据时,预设解密算法包括异或运算。步骤S251在执行时候,可以根据预设解密算法来确定根据二进制密钥中每个叶子节点存储的信息的排列顺序还是根据二进制密钥中每个叶子节点存储的信息的反向排列顺序来进行计算,例如,如果预设解密算法为异或运算,步骤S251需要根据二进制密钥中每个叶子节点存储的信息的反向排列顺序来进行运算;而对于二进制密钥中每个叶子节点存储的信息的排列顺序对计算结果没有影响的预设解密算法,步骤S251中可以任意选择一种方式执行。It should be noted that, when step S250 adopts step S251, the encrypted data is sequentially combined with the information stored in each leaf node in the binary key according to the reverse order of the information stored in each leaf node in the binary key according to the preset decryption algorithm. When performing calculation to obtain decrypted binary data, the preset decryption algorithm includes XOR operation. When step S251 is executed, it can be determined according to the preset decryption algorithm according to the arrangement order of the information stored in each leaf node in the binary key or according to the reverse arrangement order of the information stored in each leaf node in the binary key. , for example, if the preset decryption algorithm is an XOR operation, step S251 needs to perform the operation according to the reverse order of the information stored in each leaf node in the binary key; and for the information stored in each leaf node in the binary key A preset decryption algorithm that has no effect on the calculation result in the arrangement order of , can be executed in any manner in step S251 .

具体的,以步骤S240中得出的二进制密钥(01100111,01101001,01101010,01101000)与加密数据进行异或运算得到二进制待传输数据为例,步骤S161的计算过程为:(加密数据)⊕01101000⊕01101010⊕01101001⊕01100111,然后得到二进制待传输数据。Specifically, taking the binary key (01100111, 01101001, 01101010, 01101000) obtained in step S240 and the encrypted data to obtain binary data to be transmitted by XOR operation as an example, the calculation process of step S161 is: (encrypted data)⊕01101000 ⊕01101010⊕01101001⊕01100111, and then get the binary data to be transmitted.

需要说明得是,在图2所示实施例中,如果发送端通过步骤S170中发送的为待传输数据的原始格式的加密数据,则在执行步骤S250之前,接收端需要将待传输数据的原始格式的加密数据转换为二进制的加密数据,然后在执行步骤S250。在执行步骤S210之前,如果接受端接收带了发送端发送的通信请求,接收端可以向发送端发送确认回复,以便于发送端继续执行娶她流程。It should be noted that, in the embodiment shown in FIG. 2 , if the encrypted data sent by the sender in step S170 is the original format of the data to be transmitted, then before step S250 is executed, the receiver needs to convert the original format of the data to be transmitted. The encrypted data in the format is converted into binary encrypted data, and then step S250 is executed. Before step S210 is performed, if the receiving end receives the communication request sent by the sending end, the receiving end may send a confirmation reply to the sending end, so that the sending end can continue to execute the marrying her process.

图5示出了根据本发明一实施例的数据加密的装置300的示意性框图。如图5所示,该装置300包括:FIG. 5 shows a schematic block diagram of an apparatus 300 for data encryption according to an embodiment of the present invention. As shown in Figure 5, the device 300 includes:

二叉树生成单元310,用于生成用于对数据加密的二叉树;Binary tree generating unit 310, for generating a binary tree for encrypting data;

序列生成单元320,用于基于所述二叉树生成第一遍历序列和第二遍历序列,其中,通过所述第一遍历序列和所述第二遍历序列能够还原所述二叉树;a sequence generating unit 320, configured to generate a first traversal sequence and a second traversal sequence based on the binary tree, wherein the binary tree can be restored through the first traversal sequence and the second traversal sequence;

确定单元330,用于确定所述二叉树中至少一个叶子节点存储的信息作为密钥;A determination unit 330, configured to determine the information stored by at least one leaf node in the binary tree as a key;

密钥加密信息生成单元340,用于基于所述至少一个叶子节点的二叉树编码生成密钥加密信息;a key encryption information generating unit 340, configured to generate key encryption information based on the binary tree encoding of the at least one leaf node;

转换单元350,用于将所述密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥,以及将待传输数据转换为二进制待传输数据;Conversion unit 350, for converting the information stored in each leaf node in the key into binary to obtain a binary key, and converting the data to be transmitted into binary data to be transmitted;

计算单元360,用于将所述二进制密钥和所述二进制待传输数据按照预设加密算法进行计算得到加密数据;A calculation unit 360, configured to calculate the binary key and the binary data to be transmitted according to a preset encryption algorithm to obtain encrypted data;

发送单元370,用于向所述待传输数据的接收端发送所述第一遍历序列、所述第二遍历序列、所述密钥加密信息和所述加密数据。The sending unit 370 is configured to send the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data to the receiving end of the data to be transmitted.

图6示出了根据本发明又一实施例的数据加密的装置的示意性框图。如图6所示,所述装置300还包括:FIG. 6 shows a schematic block diagram of an apparatus for data encryption according to yet another embodiment of the present invention. As shown in FIG. 6, the apparatus 300 further includes:

数据包生成单元380,用于生成包括第一数据包和第二数据包的至少两个不同的数据包,所述至少两个不同的数据包携带所述密钥加密信息和所述加密数据,且所述第一数据包包括第一遍历序列,所述第二数据包包括所述第二遍历序列;a data packet generating unit 380, configured to generate at least two different data packets including a first data packet and a second data packet, the at least two different data packets carrying the key encryption information and the encrypted data, and the first data packet includes a first traversal sequence, and the second data packet includes the second traversal sequence;

所述发送单元370具体用于向所述接收端发送所述至少两个不同的数据包,其中分别发送所述第一数据包和所述第二数据包。The sending unit 370 is specifically configured to send the at least two different data packets to the receiving end, wherein the first data packet and the second data packet are sent respectively.

可以理解的是,所述密钥加密信息生成单元340具体用于基于所述至少一个叶子节点存储的信息的排列顺序对所述至少一个叶子节点的二叉树编码进行排列得到所述密钥加密信息。It can be understood that the key encryption information generating unit 340 is specifically configured to obtain the key encryption information by arranging the binary tree codes of the at least one leaf node based on the arrangement order of the information stored by the at least one leaf node.

可以理解的是,所述密钥中每个叶子节点存储的信息的排列顺序与所述二进制密钥中每个叶子节点存储的信息排序相同。It can be understood that the order of information stored in each leaf node in the key is the same as the order of information stored in each leaf node in the binary key.

所述计算单元360具体用于将所述二进制待传输数据根据所述二进制密钥中每个叶子节点存储的信息的排列顺序与所述二进制密钥中每个叶子节点存储的信息依次按照预设加密算法进行计算得到所述加密数据。The computing unit 360 is specifically configured to sequentially pre-set the binary data to be transmitted according to the arrangement order of the information stored in each leaf node in the binary key and the information stored in each leaf node in the binary key. The encryption algorithm performs calculation to obtain the encrypted data.

其中,所述预设加密算法包括异或算法。…Wherein, the preset encryption algorithm includes an exclusive OR algorithm. …

根据本发明实施例的装置300可对应于根据本发明实施例中数据加密的方法中的执行主体,并且装置300中的各个模块的上述和其它操作和/或功能分别为了实现数据加密的中的各个方法的相应流程,为了简洁,在此不再赘述。The apparatus 300 according to the embodiment of the present invention may correspond to the execution subject in the method for data encryption according to the embodiment of the present invention, and the above-mentioned and other operations and/or functions of each module in the apparatus 300 are respectively for realizing the data encryption in the For the sake of brevity, the corresponding processes of each method are not repeated here.

本发明实施例中待传输数据的装置300生成用于对数据加密的二叉树,以及能够还原二叉树的第一遍历序列和第二遍历序列发送给待传输数据的接收端,使接收端可以根据接收的两个遍历序列准确还原装置300生成的二叉树,保证对加密后待传输数据解密的准确性;装置300以二叉树中至少一个叶子节点存储的信息为密钥,并转换为二进制后与转换为二进制的待传输数据按照预设加密算法进行计算得到加密数据,这样将二叉树与二进制运算相结合对待传输数据进行加解密,提高加解密的复杂度,使数据传输的安全性更高;装置300以二叉树中至少一个叶子节点存储的信息为密钥,但是向接收端发送的是基于密钥中各叶子节点的二叉树编码生成密钥加密信息,使接收端根据密钥加密信息可以确定出对待传输数据进行加密叶子节点存储的信息,这样在装置300和接收端之间并不会直接传输密钥,而是传输对密钥进一步加密的密钥加密信息,从而提高对待传输数据加解密的信息传输的安全性,进而提高数据传输的安全性。并且本发明中在装置300和接收端进行数据传输时,不会涉及未加密的待传输数据的信息,避免了加密数据很容易被破解,降低数据传输安全性的问题。The apparatus 300 for data to be transmitted in the embodiment of the present invention generates a binary tree for encrypting data, and sends the first traversal sequence and the second traversal sequence capable of restoring the binary tree to the receiving end of the data to be transmitted, so that the receiving end can Two traversing sequences accurately restore the binary tree generated by the device 300 to ensure the accuracy of decrypting the data to be transmitted after encryption; the device 300 uses the information stored in at least one leaf node in the binary tree as a key, and converts it into binary and converts it into binary. The data to be transmitted is calculated according to a preset encryption algorithm to obtain encrypted data, so that the binary tree and binary operation are combined to encrypt and decrypt the data to be transmitted, which improves the complexity of encryption and decryption, and makes data transmission more secure; the device 300 uses the binary tree in the The information stored by at least one leaf node is a key, but the key encryption information is generated based on the binary tree encoding of each leaf node in the key, which is sent to the receiving end, so that the receiving end can determine according to the key encryption information to encrypt the data to be transmitted. The information stored by the leaf node, so that the key is not directly transmitted between the device 300 and the receiving end, but the key encryption information that further encrypts the key is transmitted, thereby improving the security of information transmission for encryption and decryption of the data to be transmitted. , thereby improving the security of data transmission. Moreover, in the present invention, when the device 300 and the receiving end perform data transmission, the information of the unencrypted data to be transmitted is not involved, which avoids the problem that the encrypted data is easily cracked and reduces the security of data transmission.

图7示出了根据本发明另一实施例的数据解密的装置400的示意性框图。如图7所示,该装置400包括:FIG. 7 shows a schematic block diagram of an apparatus 400 for decrypting data according to another embodiment of the present invention. As shown in FIG. 7, the apparatus 400 includes:

接收单元410,用于接收待传输数据的发送端发送的第一遍历序列、第二遍历序列、密钥加密信息和加密数据;a receiving unit 410, configured to receive the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data sent by the sender of the data to be transmitted;

二叉树还原单元420,用于基于第一遍历序列和第二遍历序列还原得出二叉树;The binary tree restoring unit 420 is configured to restore the binary tree based on the first traversal sequence and the second traversal sequence;

确定单元430,用于基于还原的二叉树和所述密钥加密信息确定包括所述二叉树中至少一个叶子节点存储的信息的密钥;A determination unit 430, configured to determine a key including information stored by at least one leaf node in the binary tree based on the restored binary tree and the key encryption information;

二进制转换单元440,用于将所述密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥;Binary conversion unit 440, for converting the information stored in each leaf node in the key into binary to obtain a binary key;

计算单元450,用于将所述二进制密钥和所述加密数据按照预设解密算法进行计算得到解密后的二进制待传输数据,所述预设解密算法与所述发送端对待传输数据进行加密的预设加密算法相对应;The calculation unit 450 is configured to calculate the binary key and the encrypted data according to a preset decryption algorithm to obtain the decrypted binary data to be transmitted, the preset decryption algorithm and the transmission end encrypting the data to be transmitted. The preset encryption algorithm corresponds to;

数据转换单元460,用于将所述解密后的二进制待传输数据转换为所述待传输数据。The data conversion unit 460 is configured to convert the decrypted binary data to be transmitted into the data to be transmitted.

可以理解的是,所述接收单元410具体用于接收所述发送端发送的包括第一数据包和第二数据包的至少两个不同的数据包,其中,所述至少两个不同的数据包携带所述密钥加密信息和所述加密数据,且所述第一数据包包括第一遍历序列,所述第二数据包包括所述第二遍历序列,所述第一数据包和所述第二数据包为所述发送端分别发送的。It can be understood that the receiving unit 410 is specifically configured to receive at least two different data packets including a first data packet and a second data packet sent by the sending end, wherein the at least two different data packets Carrying the key encryption information and the encrypted data, and the first data packet includes a first traversal sequence, the second data packet includes the second traversal sequence, the first data packet and the first traversal sequence The two data packets are sent by the sender respectively.

可以理解的是,所述确定单元430具体用于基于还原的二叉树和所述密钥加密信息确定所述密钥和所述密钥中每个叶子节点存储的信息的排列顺序。It can be understood that the determining unit 430 is specifically configured to determine the arrangement order of the key and the information stored by each leaf node in the key based on the restored binary tree and the key encryption information.

可以理解的是,所述计算单元450具体用于将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的排列顺序依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据,或者将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的反向排列顺序依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据。It can be understood that the computing unit 450 is specifically configured to combine the encrypted data with the information stored in each leaf node in the binary key according to the arrangement order of the information stored in each leaf node in the binary key. The decrypted binary data is obtained by calculating according to a preset decryption algorithm, or the encrypted data is sequentially combined with each leaf in the binary key according to the reverse order of the information stored in each leaf node in the binary key. The information stored by the node is calculated according to the preset decryption algorithm to obtain the decrypted binary data.

其中,当所述计算单元具体用于将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的反向排列顺序依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据时,所述预设解密算法包括异或运算。所述预设解密算法与所述预设加密算法互为逆运算。Wherein, when the computing unit is specifically configured to combine the encrypted data with the information stored in each leaf node in the binary key according to the reverse order of the information stored in each leaf node in the binary key in accordance with When a preset decryption algorithm performs calculation to obtain decrypted binary data, the preset decryption algorithm includes an exclusive OR operation. The preset decryption algorithm and the preset encryption algorithm are mutually inverse operations.

根据本发明实施例的装置400可对应于根据本发明实施例中数据解密的方法中的执行主体,并且装置400中的各个模块的上述和其它操作和/或功能分别为了实现数据解密的中的各个方法的相应流程,为了简洁,在此不再赘述。The apparatus 400 according to the embodiment of the present invention may correspond to the execution subject in the method for data decryption according to the embodiment of the present invention, and the above-mentioned and other operations and/or functions of each module in the apparatus 400 are respectively for realizing the data decryption in the For the sake of brevity, the corresponding processes of each method are not repeated here.

本发明实施例中由于发送端生成能够还原二叉树的第一遍历序列和第二遍历序列发送给装置400,所以装置400可以根据接收的两个遍历序列准确还原发送端生成的二叉树,保证对加密后待传输数据解密的准确性;装置400确定出包括至少一个叶子节点存储的信息的密钥,并转换为二进制后与解密数据按照预设解密算法进行计算得到解密的二进制待传输数据,这样将二叉树与二进制运算相结合对待传输数据进行加解密,提高解密的复杂度,使数据传输的安全性更高;装置400接收发送端发送的密钥加密信息,根据密钥加密信息可以确定出对待传输数据进行加密叶子节点存储的信息,这样在发送端和装置400之间并不会直接传输密钥,而是传输对密钥进一步加密的密钥加密信息,从而提高对待传输数据加解密的信息传输的安全性,进而提高数据传输的安全性。并且本发明中在发送端和装置400进行数据传输时,不会涉及未加密的待传输数据的信息,避免了加密数据很容易被破解,降低数据传输安全性的问题。In this embodiment of the present invention, since the transmitting end generates the first traversal sequence and the second traversing sequence capable of restoring the binary tree and sends them to the device 400, the device 400 can accurately restore the binary tree generated by the transmitting end according to the two received traversal sequences, ensuring that the encrypted The accuracy of the decryption of the data to be transmitted; the device 400 determines the key including the information stored in at least one leaf node, and converts it into binary data and performs calculation with the decrypted data according to a preset decryption algorithm to obtain the decrypted binary data to be transmitted. Combine with binary operation to encrypt and decrypt the data to be transmitted, improve the complexity of decryption, and make data transmission more secure; the device 400 receives the key encryption information sent by the sender, and can determine the data to be transmitted according to the key encryption information. The information stored in the leaf node is encrypted, so that the key is not directly transmitted between the sender and the device 400, but the key encryption information that further encrypts the key is transmitted, thereby improving the transmission efficiency of the information to be encrypted and decrypted. security, thereby improving the security of data transmission. Moreover, in the present invention, when the transmitting end and the device 400 perform data transmission, the information of the unencrypted data to be transmitted is not involved, which avoids the problem that the encrypted data is easily cracked and reduces the security of data transmission.

图8示出了根据本发明实施例的一种数据加密和解密的系统500,如图8所示,该系统500包括如图5所示数据加密的装置300和如图7所示数据解密的装置400。FIG. 8 shows a data encryption and decryption system 500 according to an embodiment of the present invention. As shown in FIG. 8 , the system 500 includes the data encryption device 300 shown in FIG. 5 and the data decryption device shown in FIG. 7 . Device 400 .

所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system, device and unit described above may refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.

以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以权利要求的保护范围为准。The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited to this. Any person skilled in the art can easily think of various equivalents within the technical scope disclosed by the present invention. Modifications or substitutions should be included within the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims (23)

1.一种数据加密的方法,包括:1. A method of data encryption, comprising: 生成用于对数据加密的二叉树;Generate a binary tree for encrypting data; 基于所述二叉树生成第一遍历序列和第二遍历序列,其中,通过所述第一遍历序列和所述第二遍历序列能够还原所述二叉树;generating a first traversal sequence and a second traversal sequence based on the binary tree, wherein the binary tree can be restored through the first traversal sequence and the second traversal sequence; 确定所述二叉树中至少一个叶子节点存储的信息作为密钥;Determine the information stored by at least one leaf node in the binary tree as a key; 基于所述至少一个叶子节点的二叉树编码生成密钥加密信息;Generate key encryption information based on the binary tree encoding of the at least one leaf node; 将所述密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥,以及将待传输数据转换为二进制待传输数据;Convert the information stored in each leaf node in the key into binary to obtain a binary key, and convert the data to be transmitted into binary data to be transmitted; 将所述二进制密钥和所述二进制待传输数据按照预设加密算法进行计算得到加密数据;Calculate the binary key and the binary data to be transmitted according to a preset encryption algorithm to obtain encrypted data; 向所述待传输数据的接收端发送所述第一遍历序列、所述第二遍历序列、所述密钥加密信息和所述加密数据。Send the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data to the receiving end of the data to be transmitted. 2.根据权利要求1所述的方法,在所述向所述待传输数据的接收端发送所述第一遍历序列、所述第二遍历序列、所述密钥加密信息和所述加密数据之前,所述方法还包括:2. The method according to claim 1, before said sending the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data to the receiving end of the data to be transmitted , the method also includes: 生成包括第一数据包和第二数据包的至少两个不同的数据包,所述至少两个不同的数据包携带所述密钥加密信息和所述加密数据,且所述第一数据包包括所述第一遍历序列、所述第二数据包包括所述第二遍历序列;generating at least two different data packets including a first data packet and a second data packet, the at least two different data packets carrying the key encryption information and the encrypted data, and the first data packet including the first traversal sequence and the second data packet include the second traversal sequence; 所述向所述待传输数据的接收端发送所述第一遍历序列、所述第二遍历序列、所述密钥加密信息和所述加密数据包括:The sending of the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data to the receiving end of the data to be transmitted includes: 向所述接收端发送所述至少两个不同的数据包,其中分别发送所述第一数据包和所述第二数据包。The at least two different data packets are sent to the receiving end, wherein the first data packet and the second data packet are sent respectively. 3.根据权利要求1所述的方法,基于所述至少一个叶子节点的二叉树编码生成密钥加密信息包括:3. The method according to claim 1, wherein generating key encryption information based on the binary tree encoding of the at least one leaf node comprises: 基于所述至少一个叶子节点存储的信息的排列顺序对所述至少一个叶子节点的二叉树编码进行排列得到所述密钥加密信息。The key encryption information is obtained by arranging the binary tree codes of the at least one leaf node based on the arrangement order of the information stored in the at least one leaf node. 4.根据权利要求1所述的方法,所述密钥中每个叶子节点存储的信息的排列顺序与所述二进制密钥中每个叶子节点存储的信息排序相同;4. The method according to claim 1, the arrangement order of the information stored in each leaf node in the key is identical to the order of the information stored in each leaf node in the binary key; 所述将所述二进制密钥和所述二进制待传输数据按照预设加密算法进行计算得到加密数据包括:The encrypted data obtained by calculating the binary key and the binary data to be transmitted according to a preset encryption algorithm includes: 将所述二进制待传输数据根据所述二进制密钥中每个叶子节点存储的信息的排列顺序与所述二进制密钥中每个叶子节点存储的信息依次按照预设加密算法进行计算得到所述加密数据。The encryption is obtained by calculating the binary data to be transmitted according to the arrangement order of the information stored in each leaf node in the binary key and the information stored in each leaf node in the binary key according to a preset encryption algorithm. data. 5.根据权利要求1至4中任一项所述的方法,所述预设加密算法包括异或算法。5. The method according to any one of claims 1 to 4, the preset encryption algorithm comprising an exclusive OR algorithm. 6.一种数据解密的方法,包括:6. A method for data decryption, comprising: 接收待传输数据的发送端发送的第一遍历序列、第二遍历序列、密钥加密信息和加密数据,其中,所述第一遍历序列、第二遍历序列是基于二叉树生成的,所述二叉树中至少一个叶子节点存储的信息为密钥,所述密钥加密信息由基于所述至少一个叶子节点的二叉树编码生成;Receive the first traversal sequence, the second traversal sequence, the key encryption information, and the encrypted data sent by the sender of the data to be transmitted, wherein the first traversal sequence and the second traversal sequence are generated based on a binary tree, and the binary tree is The information stored by at least one leaf node is a key, and the key encryption information is generated by binary tree encoding based on the at least one leaf node; 基于第一遍历序列和第二遍历序列还原得出二叉树;The binary tree is obtained by restoring based on the first traversal sequence and the second traversal sequence; 基于还原的二叉树和所述密钥加密信息确定包括所述二叉树中至少一个叶子节点存储的信息的密钥;Determine a key including information stored by at least one leaf node in the binary tree based on the restored binary tree and the key encryption information; 将所述密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥;Converting the information stored in each leaf node in the key into binary to obtain a binary key; 将所述二进制密钥和所述加密数据按照预设解密算法进行计算得到解密后的二进制待传输数据,所述预设解密算法与所述发送端对待传输数据进行加密的预设加密算法相对应;Calculate the binary key and the encrypted data according to a preset decryption algorithm to obtain the decrypted binary data to be transmitted, and the preset decryption algorithm corresponds to the preset encryption algorithm used by the sender to encrypt the data to be transmitted. ; 将所述解密后的二进制待传输数据转换为所述待传输数据。Convert the decrypted binary data to be transmitted into the data to be transmitted. 7.根据权利要求6所述的方法,所述接收待传输数据的发送端发送的第一遍历序列、第二遍历序列、密钥加密信息和加密数据包括:7. The method according to claim 6, wherein the first traversal sequence, the second traversal sequence, key encryption information and encrypted data sent by the transmitting end of the data to be transmitted comprise: 接收所述发送端发送的包括第一数据包和第二数据包的至少两个不同的数据包,其中,所述至少两个不同的数据包携带所述密钥加密信息和所述加密数据,且所述第一数据包包括第一遍历序列,所述第二数据包包括所述第二遍历序列,所述第一数据包和所述第二数据包为所述发送端分别发送的。receiving at least two different data packets including a first data packet and a second data packet sent by the sending end, wherein the at least two different data packets carry the key encryption information and the encrypted data, In addition, the first data packet includes a first traversal sequence, the second data packet includes the second traversal sequence, and the first data packet and the second data packet are respectively sent by the sender. 8.根据权利要求6所述的方法,所述基于还原的二叉树和所述密钥加密信息确定包括所述二叉树中至少一个叶子节点存储的信息的密钥包括:8. The method according to claim 6, wherein determining the key comprising the information stored by at least one leaf node in the binary tree based on the restored binary tree and the key encryption information comprises: 基于还原的二叉树和所述密钥加密信息确定所述密钥和所述密钥中每个叶子节点存储的信息的排列顺序。Based on the restored binary tree and the key encryption information, an arrangement order of the key and the information stored by each leaf node in the key is determined. 9.根据权利要求8所述的方法,所述将所述二进制密钥和所述加密数据按照预设解密算法进行计算得到解密后的二进制待传输数据包括:9. method according to claim 8, described binary key and described encrypted data are calculated according to preset decryption algorithm to obtain the binary data to be transmitted after decryption comprising: 将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的排列顺序,依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据;或者,Calculate the encrypted data according to the arrangement order of the information stored in each leaf node in the binary key, and sequentially calculate the decrypted binary data with the information stored in each leaf node in the binary key according to a preset decryption algorithm. data; or, 将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的反向排列顺序,依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据。Calculate the encrypted data according to the reverse order of the information stored in each leaf node in the binary key, and sequentially calculate the encrypted data with the information stored in each leaf node in the binary key according to a preset decryption algorithm to obtain after decryption. binary data. 10.根据权利要求9所述的方法,当将所述二进制密钥和所述加密数据按照预设解密算法进行计算得到解密后的二进制待传输数据的步骤采用将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的反向排列顺序依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据的执行方法时,所述预设解密算法包括异或运算。10. The method according to claim 9, when the binary key and the encrypted data are calculated according to a preset decryption algorithm to obtain the decrypted binary data to be transmitted after the step adopts the encrypted data according to the binary data. When the reverse arrangement order of the information stored in each leaf node in the key is sequentially calculated with the information stored in each leaf node in the binary key according to a preset decryption algorithm to obtain the decrypted binary data, the execution method is: The preset decryption algorithm includes XOR operation. 11.根据权利要求6至9中任一项所述的方法,所述预设解密算法与所述预设加密算法互为逆运算。11. The method according to any one of claims 6 to 9, wherein the preset decryption algorithm and the preset encryption algorithm are mutually inverse operations. 12.一种数据加密的装置,包括:12. An apparatus for data encryption, comprising: 二叉树生成单元,用于生成用于对数据加密的二叉树;A binary tree generating unit for generating a binary tree for encrypting data; 序列生成单元,用于基于所述二叉树生成第一遍历序列和第二遍历序列,其中,通过所述第一遍历序列和所述第二遍历序列能够还原所述二叉树;a sequence generating unit, configured to generate a first traversal sequence and a second traversal sequence based on the binary tree, wherein the binary tree can be restored through the first traversal sequence and the second traversal sequence; 确定单元,用于确定所述二叉树中至少一个叶子节点存储的信息作为密钥;a determining unit, configured to determine the information stored by at least one leaf node in the binary tree as a key; 密钥加密信息生成单元,用于基于所述至少一个叶子节点的二叉树编码生成密钥加密信息;a key encryption information generating unit, configured to generate key encryption information based on the binary tree encoding of the at least one leaf node; 转换单元,用于将所述密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥,以及将待传输数据转换为二进制待传输数据;a conversion unit, for converting the information stored in each leaf node in the key into binary to obtain a binary key, and converting the data to be transmitted into binary data to be transmitted; 计算单元,用于将所述二进制密钥和所述二进制待传输数据按照预设加密算法进行计算得到加密数据;a computing unit, configured to calculate the binary key and the binary data to be transmitted according to a preset encryption algorithm to obtain encrypted data; 发送单元,用于向所述待传输数据的接收端发送所述第一遍历序列、所述第二遍历序列、所述密钥加密信息和所述加密数据。A sending unit, configured to send the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data to the receiving end of the data to be transmitted. 13.根据权利要求12所述的装置,还包括:13. The apparatus of claim 12, further comprising: 数据包生成单元,用于生成包括第一数据包和第二数据包的至少两个不同的数据包,所述至少两个不同的数据包携带所述密钥加密信息和所述加密数据,且所述第一数据包包括第一遍历序列,所述第二数据包包括所述第二遍历序列;a data packet generating unit configured to generate at least two different data packets including a first data packet and a second data packet, the at least two different data packets carrying the key encryption information and the encrypted data, and the first data packet includes a first traversal sequence, and the second data packet includes the second traversal sequence; 所述发送单元具体用于向所述接收端发送所述至少两个不同的数据包,其中分别发送所述第一数据包和所述第二数据包。The sending unit is specifically configured to send the at least two different data packets to the receiving end, wherein the first data packet and the second data packet are sent respectively. 14.根据权利要求12所述的装置,所述密钥加密信息生成单元具体用于基于所述至少一个叶子节点存储的信息的排列顺序对所述至少一个叶子节点的二叉树编码进行排列得到所述密钥加密信息。14. The device according to claim 12, wherein the key encryption information generation unit is specifically configured to arrange the binary tree coding of the at least one leaf node based on the arrangement order of the information stored by the at least one leaf node to obtain the Key to encrypt information. 15.根据权利要求14所述的装置,所述密钥中每个叶子节点存储的信息的排列顺序与所述二进制密钥中每个叶子节点存储的信息排序相同;15. The device according to claim 14, the arrangement order of the information stored in each leaf node in the key is the same as the order of the information stored in each leaf node in the binary key; 所述计算单元具体用于将所述二进制待传输数据根据所述二进制密钥中每个叶子节点存储的信息的排列顺序与所述二进制密钥中每个叶子节点存储的信息依次按照预设加密算法进行计算得到所述加密数据。The computing unit is specifically configured to encrypt the binary data to be transmitted according to the arrangement order of the information stored by each leaf node in the binary key and the information stored by each leaf node in the binary key in sequence according to a preset sequence. The algorithm performs calculation to obtain the encrypted data. 16.根据权利要求12-15任一项所述的装置,所述预设加密算法包括异或算法。16. The apparatus according to any one of claims 12-15, wherein the preset encryption algorithm comprises an exclusive OR algorithm. 17.一种数据解密的装置,包括:17. An apparatus for decrypting data, comprising: 接收单元,用于接收待传输数据的发送端发送的第一遍历序列、第二遍历序列、密钥加密信息和加密数据,其中,所述第一遍历序列、第二遍历序列是基于二叉树生成的,所述二叉树中至少一个叶子节点存储的信息为密钥,所述密钥加密信息由基于所述至少一个叶子节点的二叉树编码生成;a receiving unit, configured to receive the first traversal sequence, the second traversal sequence, the key encryption information and the encrypted data sent by the sender of the data to be transmitted, wherein the first traversal sequence and the second traversal sequence are generated based on a binary tree , the information stored by at least one leaf node in the binary tree is a key, and the key encryption information is generated by the binary tree encoding based on the at least one leaf node; 二叉树还原单元,用于基于第一遍历序列和第二遍历序列还原得出二叉树;The binary tree restoration unit is used to restore the binary tree based on the first traversal sequence and the second traversal sequence; 确定单元,用于基于还原的二叉树和所述密钥加密信息确定包括所述二叉树中至少一个叶子节点存储的信息的密钥;a determining unit, configured to determine a key including information stored by at least one leaf node in the binary tree based on the restored binary tree and the key encryption information; 二进制转换单元,用于将所述密钥中每个叶子节点存储的信息转换为二进制得到二进制密钥;A binary conversion unit, for converting the information stored in each leaf node in the key into binary to obtain a binary key; 计算单元,用于将所述二进制密钥和所述加密数据按照预设解密算法进行计算得到解密后的二进制待传输数据,所述预设解密算法与所述发送端对待传输数据进行加密的预设加密算法相对应;The calculation unit is used for calculating the binary key and the encrypted data according to a preset decryption algorithm to obtain the decrypted binary data to be transmitted, the preset decryption algorithm and the transmission terminal encrypting the data to be transmitted. Let the encryption algorithm correspond; 数据转换单元,用于将所述解密后的二进制待传输数据转换为所述待传输数据。A data conversion unit, configured to convert the decrypted binary data to be transmitted into the data to be transmitted. 18.根据权利要求17所述的装置,所述接收单元具体用于接收所述发送端发送的包括第一数据包和第二数据包的至少两个不同的数据包,其中,所述至少两个不同的数据包携带所述密钥加密信息和所述加密数据,且所述第一数据包包括第一遍历序列,所述第二数据包包括所述第二遍历序列,所述第一数据包和所述第二数据包为所述发送端分别发送的。18. The apparatus according to claim 17, wherein the receiving unit is specifically configured to receive at least two different data packets including a first data packet and a second data packet sent by the transmitting end, wherein the at least two data packets are different data packets carry the key encryption information and the encrypted data, and the first data packet includes the first traversal sequence, the second data packet includes the second traversal sequence, and the first data packet includes the first traversal sequence. The packet and the second data packet are sent by the sender respectively. 19.根据权利要求17所述的装置,所述确定单元具体用于基于还原的二叉树和所述密钥加密信息确定所述密钥和所述密钥中每个叶子节点存储的信息的排列顺序。19. The apparatus according to claim 17, wherein the determining unit is specifically configured to determine the arrangement order of the key and the information stored by each leaf node in the key based on the restored binary tree and the key encryption information . 20.根据权利要求19所述的装置,所述计算单元具体用于将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的排列顺序依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据,或者将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的反向排列顺序依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据。20. The device according to claim 19, wherein the computing unit is specifically configured to sequentially associate the encrypted data with each of the binary keys according to the arrangement order of the information stored in each leaf node in the binary key. The information stored in the leaf node is calculated according to the preset decryption algorithm to obtain the decrypted binary data, or the encrypted data is sequentially combined with the binary key according to the reverse order of the information stored in each leaf node in the binary key. The information stored in each leaf node in the key is calculated according to the preset decryption algorithm to obtain the decrypted binary data. 21.根据权利要求17-20任一项所述的装置,当所述计算单元具体用于将所述加密数据根据所述二进制密钥中每个叶子节点存储的信息的反向排列顺序依次与所述二进制密钥中每个叶子节点存储的信息按照预设解密算法进行计算得到解密后的二进制数据时,所述预设解密算法包括异或运算。21. The device according to any one of claims 17-20, when the computing unit is specifically used to sequentially combine the encrypted data with the information stored in each leaf node in the binary key according to the reverse order of the information stored in the leaf node. When the information stored in each leaf node in the binary key is calculated according to a preset decryption algorithm to obtain decrypted binary data, the preset decryption algorithm includes an exclusive OR operation. 22.根据权利要求17-20任一项所述的装置,所述预设解密算法与所述预设加密算法互为逆运算。22. The apparatus according to any one of claims 17-20, wherein the preset decryption algorithm and the preset encryption algorithm are mutually inverse operations. 23.一种数据加密和解密的系统,包括如权利要求12至16任一项所述的数据加密的装置和如权利要求17至22任一项所述的数据解密的装置。23. A system for data encryption and decryption, comprising the data encryption device as claimed in any one of claims 12 to 16 and the data decryption device as claimed in any one of claims 17 to 22.
CN201610990502.2A 2016-11-10 2016-11-10 Data encryption and decryption method, device and system Active CN108075879B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610990502.2A CN108075879B (en) 2016-11-10 2016-11-10 Data encryption and decryption method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610990502.2A CN108075879B (en) 2016-11-10 2016-11-10 Data encryption and decryption method, device and system

Publications (2)

Publication Number Publication Date
CN108075879A CN108075879A (en) 2018-05-25
CN108075879B true CN108075879B (en) 2021-03-09

Family

ID=62154504

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610990502.2A Active CN108075879B (en) 2016-11-10 2016-11-10 Data encryption and decryption method, device and system

Country Status (1)

Country Link
CN (1) CN108075879B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109495446B (en) * 2018-10-02 2020-12-22 复旦大学 Order-preserving encryption algorithm based on balanced sorting tree storage structure
CN109787755B (en) * 2018-12-14 2021-11-12 魏勇 Key generation method, key generation device and electronic equipment
CN110213228B (en) * 2019-04-25 2021-09-07 平安科技(深圳)有限公司 Method, device, storage medium and computer equipment for authenticating communication
CN110414567B (en) * 2019-07-01 2020-08-04 阿里巴巴集团控股有限公司 Data processing method and device and electronic equipment
CN110492992A (en) * 2019-07-22 2019-11-22 哈尔滨工程大学 A kind of data encryption and transmission method based on radio RF recognition technology
US11695429B2 (en) * 2021-07-29 2023-07-04 Samsung Display Co., Ltd. Systems and methods for transition encoding with protected key
CN115361680B (en) * 2022-10-20 2023-02-17 华信咨询设计研究院有限公司 Medical insurance data intelligent sharing and exchanging system
CN117668886B (en) * 2024-01-25 2024-04-12 南通云链通信息科技有限公司 Secure storage method for applet development data
CN119203206B (en) * 2024-08-08 2025-07-15 内蒙古电力(集团)有限责任公司内蒙古电力经济技术研究院分公司 Power data privacy protection method based on blockchain

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7095850B1 (en) * 2000-09-29 2006-08-22 Cisco Technology, Inc. Encryption method and apparatus with forward secrecy and random-access key updating method
CN101582760A (en) * 2008-05-16 2009-11-18 中国科学院研究生院 Key encrypting and storing method based on tree structure
CN103414552A (en) * 2013-07-31 2013-11-27 深圳信息职业技术学院 Method and device for encrypting and decrypting by using binary tree traversal mode
CN105245315A (en) * 2015-10-27 2016-01-13 成都卫士通信息产业股份有限公司 Method and system for information secrecy storage by encoding

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101285597B1 (en) * 2006-06-29 2013-07-15 삼성전자주식회사 Method of updating group key and group key update device using the same

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7095850B1 (en) * 2000-09-29 2006-08-22 Cisco Technology, Inc. Encryption method and apparatus with forward secrecy and random-access key updating method
CN101582760A (en) * 2008-05-16 2009-11-18 中国科学院研究生院 Key encrypting and storing method based on tree structure
CN103414552A (en) * 2013-07-31 2013-11-27 深圳信息职业技术学院 Method and device for encrypting and decrypting by using binary tree traversal mode
CN105245315A (en) * 2015-10-27 2016-01-13 成都卫士通信息产业股份有限公司 Method and system for information secrecy storage by encoding

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种改进的数据加密解密算法;王玉琼;《阜阳职业技术学院学报》;20171231;第28卷(第4期);全文 *

Also Published As

Publication number Publication date
CN108075879A (en) 2018-05-25

Similar Documents

Publication Publication Date Title
CN108075879B (en) Data encryption and decryption method, device and system
CN107196763B (en) SM2 algorithm collaborative signature and decryption method, device and system
EP3622663B1 (en) Key agreement devices and method
TWI668985B (en) Quantum key distribution, privacy amplification and data transmission method, device and system
CN106411521B (en) Identity authentication method, device and system for quantum key distribution process
CN113038468A (en) Method for distributing and negotiating quantum key of wireless terminal of Internet of things
US10511581B2 (en) Parallelizable encryption using keyless random permutations and authentication using same
TWI489847B (en) Data encryption method, data verification method and electronic apparatus
CN109274502B (en) Method and device for creating public key encryption and key signature and readable storage medium
CN107959566A (en) Quantal data key agreement system and quantal data cryptographic key negotiation method
CN111049650A (en) SM2 algorithm-based collaborative decryption method, device, system and medium
EP3854052B1 (en) Computer implemented system and method for sharing a common secret
US11563566B2 (en) Key splitting
CN109547413B (en) Access control method of convertible data cloud storage with data source authentication
CN114499857A (en) Method for realizing data correctness and consistency in big data quantum encryption and decryption
CN111786777B (en) Stream data encryption and decryption method, device, system and storage medium
CN113849831A (en) A two-party collaborative signature and decryption method and system based on SM2 algorithm
CN111404671A (en) Mobile quantum secure communication method, gateway, mobile terminal and server
CN105162585A (en) Efficient privacy protecting session key agreement method
CN107786338B (en) Shared Platform in Dynamic Password Verification
CN114070549A (en) Key generation method, device, equipment and storage medium
CN109889327B (en) Shared key generation method and device
CN111198781B (en) Computer-implemented method for error correction coding and encryption of files
CN114070550A (en) Information processing method, device, equipment and storage medium
CN115460020B (en) Data sharing method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant