A method of encrypting and transmitting information and a decryption method

By randomly generating an initial key and using a three-stage encryption method with a specific number of key bits, combined with the HMAC-SHA256 algorithm to generate verification information, the problem of low security in traditional encryption methods is solved, achieving highly secure and efficient encrypted information transmission.

CN114285610BActive Publication Date: 2026-04-28卢英东
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
卢英东
Filing Date
2021-12-07
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

Traditional encryption methods have low security and low encryption efficiency, and are easily cracked by exhaustive methods and mathematical statistical methods, which affects the data security of communication networks.

Method used

An initial key is randomly generated, and encryption is performed three times using a padding method and a symmetric encryption algorithm. The number of encryption times and methods are determined by a specific number of key bits. Verification information is generated by combining the HMAC-SHA256 algorithm and inserted into the ciphertext to provide decryption verification.

Benefits of technology

It improves the security and confidentiality of encrypted information, enhances the data security of communication networks, and prevents ciphertext from being tampered with and cracked.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114285610B_ABST
    Figure CN114285610B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of information security, in particular to a method for encrypting and transmitting information, which comprises the following steps: providing initial information to be encrypted, randomly generating an initial key, adding padding bytes to the initial information to be encrypted through a padding method to obtain padding plaintext, and performing first encryption on the padding plaintext through a symmetric encryption algorithm to obtain first encryption ciphertext; determining the encryption times of second encryption and the encryption method of second encryption according to the initial key, and performing second encryption on the first encryption ciphertext to obtain second encryption ciphertext; performing verification calculation on the second encryption ciphertext to obtain verification information, and inserting the verification information into the second encryption ciphertext in segments according to the key to obtain third encryption ciphertext; and transmitting the third encryption ciphertext. The method for encrypting and transmitting information provided by the application improves the security of information in the transmission process.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0002] This invention relates to the field of information security technology, and in particular to a method for encrypting and transmitting information, and a decryption method. [Background Technology]

[0004] Currently, communication technology has permeated all aspects of life, from online shopping and finance to daily social interactions. Information is constantly being transmitted, making information security a crucial aspect of daily life. Encryption algorithms are the core technology for ensuring the secure transmission and storage of information. While computer storage capacity and computing power have increased, traditional encryption methods suffer from low security and efficiency, making it possible to crack traditional encryption algorithms through brute-force methods and mathematical statistical methods. This negatively impacts the data security of communication networks. [Summary of the Invention]

[0006] To address the issues of low security and low encryption efficiency in traditional information encryption transmission, this invention provides a method for encrypting and transmitting information, as well as a decryption method.

[0007] To solve the above-mentioned technical problems, the present invention provides the following technical solution: a method for encrypting and transmitting information, comprising the following steps: providing initial information to be encrypted, randomly generating an initial key, adding padding bytes to the initial information to be encrypted using a padding method to obtain padding plaintext, and then performing a first encryption on the padding plaintext using a symmetric encryption algorithm to obtain a first-encrypted ciphertext;

[0008] The number of encryption times and the encryption method for the second encryption are determined based on the initial key, and the first encryption ciphertext is then encrypted again to obtain the second encryption ciphertext.

[0009] The verification information is obtained by performing verification calculations on the secondary encrypted ciphertext, and the verification information is inserted into the secondary encrypted ciphertext in segments according to the key to obtain the tertiary encrypted ciphertext;

[0010] Transmit the encrypted ciphertext three times.

[0011] Preferably, the process of obtaining the double-encrypted ciphertext specifically involves: first determining the number of times the double encryption is performed based on the key, and then determining the method of the double encryption based on the key;

[0012] When the secondary encryption is performed multiple times, the method for each secondary encryption is determined sequentially based on the key.

[0013] Preferably, the number of encryption attempts and the encryption method used in obtaining the secondary encrypted ciphertext are determined by a specific number of bits in the key.

[0014] Preferably, the method for determining the number of encryption times during the process of obtaining the secondary encrypted ciphertext is as follows:

[0015] C is defined as the number of encryption attempts, W is defined as the ASCII code of the first specific number of bits of the key, and w is a positive integer less than W. The number of encryption attempts C is determined by the function C = P(W, w), where P(W, w) is the function that modulo W with respect to w. After passing in the parameters W and w, the value of the function P(W, w) is the number of encryption attempts.

[0016] Preferably, the method for determining the encryption method during the process of obtaining the secondary encrypted ciphertext is as follows: Define array a[] as the encryption method array, define M as the ASCII code of the second specific number of bits of the key, define m as a positive integer less than M, and define Q{C, P(M, m), a[]} as a loop algorithm, the specific steps of which include:

[0017] Determine if C is greater than 0. If C is not greater than 0, stop the loop and encrypt the encrypted ciphertext using the array of encryption methods. If C is greater than 0, continue execution.

[0018] The value obtained by P(M, m) is placed into array a[]. If array a[] is empty, it is placed at the beginning of array a[]. If a[] is not empty, it is searched from the beginning of array a[] backwards until an empty space is found to store the new value.

[0019] The second specific number is incremented by 1, the value of C is decremented by 1, and then the loop jumps back to the step of checking whether C is greater than 0.

[0020] Based on the number sequence in the encryption method array determined by the loop algorithm, the corresponding encryption method is selected to encrypt the first-encrypted ciphertext twice in sequence to obtain the second-encrypted ciphertext.

[0021] Preferably, after the loop algorithm stops and before the first encrypted ciphertext is encrypted a second time, the following steps are further included:

[0022] Define H as the ASCII code of a specific number of bits of the key corresponding to the encryption order, define h as the value that determines the encryption order, define the function R(H, 2) as the function of taking the remainder of H with respect to 2, and h = R(H, 2), and determine whether to reverse the array a[] based on the value of h.

[0023] Preferably, during the process of obtaining the three-stage encrypted ciphertext, the HMAC-SHA256 algorithm is used to calculate the secondary encrypted ciphertext to obtain verification information. The verification information is divided into three segments, and the segmented verification information is inserted into the secondary encrypted ciphertext from the specific number of bits of the key, respectively, to obtain the tertiary encrypted ciphertext.

[0024] A decryption method for decrypting the encrypted information as described above includes the following steps:

[0025] Receive encrypted ciphertext three times;

[0026] Verification information is extracted from the three encrypted ciphertexts to confirm that the three encrypted ciphertexts have not been tampered with, and then decryption is performed through the decryption process.

[0027] Remove padding bytes to obtain plaintext.

[0028] Preferably, the method for confirming that the encrypted ciphertext has not been tampered with is as follows:

[0029] The segmented verification information is extracted from the three encrypted ciphertexts. The verification information of the three encrypted ciphertexts is calculated using the decryption algorithm corresponding to the three encryption algorithms. The extracted verification information is compared with the calculated verification information. If it is confirmed that there is no error, it means that the ciphertext has not been tampered with.

[0030] Preferably, the decryption process is the reverse of the process of obtaining the secondary encrypted ciphertext and the process of obtaining the primary encrypted ciphertext.

[0031] Compared with existing technologies, the method for encrypting and transmitting information provided by this invention has the following beneficial effects:

[0032] 1. In the method for encrypting and transmitting information provided in the embodiments of the present invention, the initial information to be encrypted is encrypted by selecting the number of encryption times and the encryption method according to the specific number of bits of the randomly generated initial key, and the verification information is calculated and inserted into the ciphertext. Because the initial key is random, that is, the number of encryption times and the encryption method are random, the ciphertext generated in the end is not generated by a single encryption method, which makes the ciphertext highly confidential and makes it more difficult for attackers to decipher the ciphertext using brute force.

[0033] 2. Determining the number of encryption attempts first, and then selecting the encryption method based on the number of attempts, makes the encryption process clearer and makes it easier to correlate the encryption and decryption processes.

[0034] 3. By using a specific number of bits in the key to determine the number of encryption attempts and the encryption method, the number of encryption attempts and the encryption method are no longer fixed, thus improving the security of the ciphertext.

[0035] 4. Using a specific remainder of a certain number of bits in the key to determine the number of encryption attempts is a more flexible method that improves the overall security of the encryption method.

[0036] 5. The encryption method is determined using a specific remainder of a key with a specific number of bits. An array of encryption methods is created based on the number of encryption attempts. Each encryption method is then added to this array, and the first-time encrypted ciphertext is encrypted using this array. This method, by first determining the encryption method array and then encrypting the first-time encrypted ciphertext based on it, makes the encryption process more flexible. The permutations and combinations of different encryption methods with different attempts further improve the reliability of obtaining the second-time encrypted ciphertext.

[0037] 6. The security of obtaining the secondary encrypted ciphertext is further enhanced by determining whether to reverse the encryption method array based on the specific remainder of a specific number of bits in the key.

[0038] 7. Using the HMAC-SHA256 algorithm, generate 32 bytes of verification information from the double-encrypted ciphertext. Then, insert the verification information into the ciphertext in segments according to specific key lengths. During decryption, check whether the verification information has been altered to determine if the ciphertext has been leaked, thus verifying the security of the ciphertext.

[0039] 8. This invention provides a decryption method for decrypting encrypted information as described above, enabling the receiver to receive and decrypt encrypted information sent by the sender. This improves the information exchange process, enhancing the security of the entire information transmission process from encryption to transmission and then from reception to decryption. [Attached Image Description]

[0041] Figure 1 This is a schematic diagram of a method for encrypting and transmitting information according to the first embodiment of the present invention.

[0042] Figure 2 This is a flowchart illustrating the process of obtaining secondary encrypted ciphertext through a method for encrypting and transmitting information, as provided in the first embodiment of the present invention.

[0043] Figure 3 This is a schematic diagram of the loop algorithm in the process of obtaining the secondary encrypted ciphertext in the first embodiment of the present invention.

[0044] Figure 4 This is a flowchart of the encryption process of a method for encrypting and transmitting information provided in the first embodiment of the present invention.

[0045] Figure 5 This is a flowchart of the decryption process of a decryption method provided in the second embodiment of the present invention.

[0046] Explanation of reference numerals in the attached diagram:

[0047] 1. A method for encrypting and transmitting information.

Detailed Implementation Methods

[0049] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0050] Please see Figure 1 The first embodiment of the present invention provides a method 1 for encrypting and transmitting information, comprising the following steps:

[0051] An encryption process involves providing initial information to be encrypted, randomly generating an initial key, adding padding bytes to the initial information to be encrypted using a padding method to obtain padding plaintext, and then performing a first encryption on the padding plaintext using an encryption algorithm to obtain first encrypted ciphertext.

[0052] The process of obtaining the secondary encrypted ciphertext involves determining the number of encryption times and the encryption method for the secondary encryption based on the key, and then performing secondary encryption on the primary encrypted ciphertext to obtain the secondary encrypted ciphertext.

[0053] The process involves obtaining three encrypted ciphertexts, verifying the second encrypted ciphertext to obtain verification information, and inserting the verification information into the second encrypted ciphertext in segments according to the key to obtain the three encrypted ciphertexts.

[0054] Transmit the encrypted ciphertext three times.

[0055] In this embodiment, by encrypting the initial information three times before transmitting it, it becomes more difficult for attackers to crack the encrypted information, thus improving the security of the encrypted information.

[0056] Specifically, in one encryption process, a random 256-bit key is generated using a random function, and 256-bit AES encryption is employed. Before encrypted communication, both parties have agreed upon a security key encoded using Base64. Because 256-bit AES encryption is used, the plaintext length must be a multiple of 256 bits; therefore, plaintext shorter than 256 bits is padded. This embodiment uses the PKCS7 method to padded the plaintext, resulting in padded plaintext. The padded plaintext is then encrypted using the CBC encryption mode of the 256-bit AES encryption method, yielding the first encrypted ciphertext.

[0057] Optionally, the encoding method, encryption mode, and padding method in an encryption process can be replaced according to the actual situation, and the encryption algorithm can only be replaced with other symmetric encryption methods.

[0058] Please see Figure 2In the process of obtaining the double-encrypted ciphertext, the number of times the double encryption is performed is first determined based on the key, and then the method of double encryption is determined based on the key. When the number of double encryption operations is multiple, the method of double encryption is determined sequentially for each operation based on the key. Determining the number of encryption operations first, and then selecting the encryption method based on the number of encryption operations, makes the encryption process clearer and makes it easier to correlate the encryption and decryption processes.

[0059] Furthermore, the number of encryption attempts and the encryption method used in obtaining the secondary encrypted ciphertext are determined by a specific number of bits in the key. By using a specific remainder of the key's specific number of bits to determine the number of encryption attempts and the encryption method, the number of encryption attempts and the encryption method are no longer fixed, thus improving the security of the ciphertext.

[0060] Specifically, the method for obtaining the number of encryptions during the process of obtaining the double-encrypted ciphertext is as follows:

[0061] First, define C as the number of encryption attempts, W as the ASCII code of the character at the first specific bit position of the key, and w as a positive integer less than W. Then, establish a modulo function P, which can accept two positive integers. In this embodiment, W and w are input, and the value of W modulo w calculated by function P(W, w) is assigned to C to obtain the number of encryption attempts, i.e., C = P(W, w). The first specific bit position and w can be different in each encryption process; they can be uniformly agreed upon before encryption or selected using a selection algorithm. When the first specific bit position and w are uniformly agreed upon before encryption, since the key is generated by a random function, even if the first specific bit position is determined, the ASCII code W of the character at the first specific bit position can still have good randomness, and the number of encryption attempts C determined by function P(W, w) also has good randomness. When a selection algorithm is introduced to select the first specific bit position and w for each encryption, the calculated number of encryption attempts can be made more random. Using the specific remainder of the key's specific bit position to determine the number of encryption attempts is a more flexible method, improving the overall security of the encryption algorithm.

[0062] Please see Figure 3 In the process of obtaining the secondary encrypted ciphertext, after determining the number of encryption attempts, it is necessary to determine the encryption method. The specific method for determining the encryption method is as follows: Define array a[] as the encryption method array, define M as the ASCII code of the character at the second specific bit position of the key, define m as a positive integer less than M, and define Q{C, P(M, m), a[]} as a loop algorithm. The specific steps of the loop algorithm include:

[0063] Determine if C is greater than 0. If C is not greater than 0, stop the loop and encrypt the ciphertext using the encryption method array. If C is greater than 0, continue execution to the next step.

[0064] The value obtained by P(M, m) is placed into array a[]. If array a[] is empty, it is placed at the beginning of array a[]. If a[] is not empty, it is searched from the beginning of array a[] backwards until an empty space is found to store the new value.

[0065] The second specific number is incremented by 1, the value of C is decremented by 1, and then the loop jumps back to the step of checking whether C is greater than 0.

[0066] Based on the number sequence in the encryption method array determined by the loop algorithm, the corresponding encryption method is selected to encrypt the first-encrypted ciphertext twice in sequence to obtain the second-encrypted ciphertext.

[0067] Specifically, in the loop algorithm, the value of the encryption count C is first determined to decide whether to continue the loop. When C is greater than 0, M and m are passed to the modulo function P. The values ​​calculated by P(M, m) are then filled into the encryption method array a[]. To determine the next encryption method, the second specific bit is shifted down to obtain the ASCII code of the next character, thus incrementing the second specific bit by 1. The encryption count is the loop count of the loop algorithm, which is also the length of the encryption method array a[]. After one loop, C is decremented by 1, and the algorithm returns to the first step of the loop algorithm to check the value of C. When C is not greater than 0, it means that the encryption method array a[] is filled, and the loop is exited. At this point, the encryption method array is filled with a sequence of numbers. The corresponding encryption method is then selected based on the sequence of numbers in the encryption method array to perform secondary encryption on the first encrypted ciphertext, resulting in the secondary encrypted ciphertext. The encryption method is determined by the specific remainder of the key's specific bits, and an encryption method array is created based on the encryption count. The encryption methods are then filled into the encryption method array, and the first encrypted ciphertext is encrypted using the encryption method array. By first determining the array of encryption methods and then encrypting the ciphertext once based on the array, the encryption method becomes more flexible. The permutation and combination of different encryption methods for different times further improves the reliability of obtaining the ciphertext for the second encryption.

[0068] Please participate Figure 4 Alternatively, the encryption methods include the following: circular right shift, segment reversal, random arrangement, digit swapping, and Caesar encryption.

[0069] As can be understood, a circular right shift means shifting the entire ciphertext to the right by k bits. The principle is to fill the high bits with the low bits, where k is determined by the first character of the key.

[0070] Reverse ordering means reversing the arrangement of a ciphertext.

[0071] Scrambling means shuffling the bits in a ciphertext. The principle is to take a ciphertext segment s2 with a length of 32 bytes, convert the lower four bits of the first byte of the key into a decimal integer a, and the higher four bits into a decimal integer b. Then, swap the character s2[a] at position a with the character s2[b] at position b. Repeat this process m times, where m is the length of the key.

[0072] A digit swap means swapping the position of a character in the ciphertext that is a multiple of 4 with the character preceding it. For example, swapping the third character with the fourth character, the seventh character with the eighth character, and so on until the entire text is swapped.

[0073] The Caesar cipher works by offsetting all letters in the input string backwards (or forwards) on the ASCII table according to the lower four hexadecimal bits of each key character. This process is repeated in cycles of key length *m* until the entire input string is encrypted. It's important to note that the initial information to be encrypted is padded during each encryption process, and its length is an integer multiple of the key. This method allows for different encryption methods to be generated for different keys used on different products.

[0074] Furthermore, after the loop stops and before performing a second encryption on the first encrypted ciphertext, the following steps are also included:

[0075] H is defined as the ASCII code of the character at the third specific bit position of the key corresponding to the encryption order. h is defined as the value that determines the encryption order. R(H, 2) is defined as the function of H modulo 2, and h = R(H, 2). The value of h determines whether to reverse the array a[]. Specifically, when the value of h is 0, the array is reversed; when the value of h is not 0, no operation is performed on the array. Determining whether to reverse the encryption array based on the specific remainder of the third specific bit position of the key further improves the security of obtaining the secondary encrypted ciphertext.

[0076] In the process of obtaining the triple-encrypted ciphertext, the HMAC-SHA256 algorithm is used to calculate the verification information from the secondary encrypted ciphertext. This verification information is divided into three segments. Based on a specific number of bits in the key, each segment of the verification information is inserted into a different bit position of the secondary encrypted ciphertext to obtain the triple-encrypted ciphertext. The HMAC-SHA256 algorithm is then used to perform a hash operation on the secondary encrypted ciphertext, yielding 32 bytes of verification information. This verification information is divided into three segments, and then, based on the ASCII code of the character at the fourth specific bit position of the key, each of the three segments is inserted into a different bit position of the secondary encrypted ciphertext. After each insertion, the fourth specific bit position is shifted one position to the right. This step is a signature process, which effectively prevents ciphertext tampering, confuses attackers, and provides a certain degree of encryption while having almost no impact on signal transmission efficiency.

[0077] Please see Figure 5 The second embodiment of the present invention provides a decryption method for decrypting the triple-encrypted ciphertext of the first embodiment, and further includes the following steps:

[0078] The verification information, divided into three 32-byte segments, is extracted from the three encrypted ciphertexts. The verification information is then calculated using the HMAC-SHA256 algorithm. Comparing this verified information with the extracted information confirms its accuracy, indicating that the ciphertext has not been tampered with. This step is the signature verification process, which reduces the ciphertext length by 32 bytes. After confirming that the three encrypted ciphertexts have not been tampered with, the text is decrypted, and then the padding bytes from the first encryption process are removed to obtain the plaintext.

[0079] Understandingly, the decryption process is the inverse of obtaining the double-encrypted ciphertext and the single-encryption process. A circular right shift corresponds to a circular left shift, segment reversal corresponds to reverse segment reversal, scrambled arrangement becomes reverse scrambled arrangement, bit swapping becomes reverse bit swapping, and Caesar encryption becomes Caesar decryption. The inverse process also requires a key, selecting the decryption method from the resulting encryption method array. The principle is the same as encryption, only the order is reversed. Then, 256-bit AES (CBC mode) is used to decrypt using the key, and finally, the padding bytes are removed to obtain the desired plaintext.

[0080] In the embodiments provided by this invention, it should be understood that "B corresponding to A" means that B is associated with A, and B can be determined based on A. However, it should also be understood that determining B based on A does not mean determining B solely based on A; B can also be determined based on A and / or other information.

[0081] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of the invention. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Those skilled in the art should also recognize that the embodiments described in the specification are optional embodiments, and the actions and modules involved are not necessarily essential to the invention.

[0082] In various embodiments of the present invention, it should be understood that the sequence number of each process does not necessarily imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0083] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It is particularly important to note that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0084] Compared with existing technologies, the method for encrypting and transmitting information provided by this invention has the following beneficial effects:

[0085] 1. In the method for encrypting and transmitting information provided in the embodiments of the present invention, the initial information to be encrypted is encrypted by selecting the number of encryption times and the encryption method according to the specific number of bits of the randomly generated initial key, and the verification information is calculated and inserted into the ciphertext. Because the initial key is random, that is, the number of encryption times and the encryption method are random, the ciphertext generated in the end is not generated by a single encryption method, which makes the ciphertext highly confidential and makes it more difficult for attackers to decipher the ciphertext using brute force.

[0086] 2. Determining the number of encryption attempts first, and then selecting the encryption method based on the number of attempts, makes the encryption process clearer and makes it easier to correlate the encryption and decryption processes.

[0087] 3. By using a specific number of bits in the key to determine the number of encryption attempts and the encryption method, the number of encryption attempts and the encryption method are no longer fixed, thus improving the security of the ciphertext.

[0088] 4. Using a specific remainder of a certain number of bits in the key to determine the number of encryption attempts is a more flexible method that improves the overall security of the encryption method.

[0089] 5. The encryption method is determined using a specific remainder of a key with a specific number of bits. An array of encryption methods is created based on the number of encryption attempts. Each encryption method is then added to this array, and the first-time encrypted ciphertext is encrypted using this array. This method, by first determining the encryption method array and then encrypting the first-time encrypted ciphertext based on it, makes the encryption process more flexible. The permutations and combinations of different encryption methods with different attempts further improve the reliability of obtaining the second-time encrypted ciphertext.

[0090] 6. The security of obtaining the secondary encrypted ciphertext is further enhanced by determining whether to reverse the encryption method array based on the specific remainder of a specific number of bits in the key.

[0091] 7. Using the HMAC-SHA256 algorithm, generate 32 bytes of verification information from the double-encrypted ciphertext. Then, insert the verification information into the ciphertext in segments according to specific key lengths. During decryption, check whether the verification information has been altered to determine if the ciphertext has been leaked, thus verifying the security of the ciphertext.

[0092] 8. This invention provides a decryption method for decrypting encrypted information as described above, enabling the receiver to receive and decrypt encrypted information sent by the sender. This improves the information exchange process, enhancing the security of the entire information transmission process from encryption to transmission and then from reception to decryption.

[0093] The foregoing has provided a detailed description of a method for encrypting and transmitting information and a method for decrypting information, as disclosed in the embodiments of the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention. Any modifications, equivalent substitutions, and improvements made within the principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for encrypting and transmitting information, characterized in that: Includes the following steps: Provide initial information to be encrypted, randomly generate an initial key, add padding bytes to the initial information to be encrypted using a padding method to obtain padding plaintext, and then encrypt the padding plaintext for the first time using a symmetric encryption algorithm to obtain encrypted ciphertext. The number of encryption times and the encryption method for the second encryption are determined based on the initial key, and the first encryption ciphertext is then encrypted again to obtain the second encryption ciphertext. The number of encryptions and the encryption method in the process of obtaining the secondary encrypted ciphertext are determined by a specific number of bits in the key. Specifically, the method for determining the number of encryptions in the process of obtaining the secondary encrypted ciphertext is as follows: C is defined as the number of encryptions, W is defined as the ASCII code of the character at the first specific bit of the key, w is a positive integer less than W, and the number of encryptions C is determined by the function C = P(W, w). The function P(W, w) is a function that modulo W with respect to w. After passing in the parameters W and w, the value of the function P(W, w) is the number of encryptions. The verification information is obtained by performing verification calculations on the secondary encrypted ciphertext, and the verification information is inserted into the secondary encrypted ciphertext in segments according to the key to obtain the tertiary encrypted ciphertext; Transmit the encrypted ciphertext three times.

2. The method for encrypting and transmitting information as described in claim 1, characterized in that: The process of obtaining the double-encrypted ciphertext is as follows: first, determine the number of times the double encryption is performed based on the key, and then determine the method of double encryption based on the key; When the secondary encryption is performed multiple times, the method for each secondary encryption is determined sequentially based on the key.

3. The method for encrypting and transmitting information as described in claim 1, characterized in that: The specific method for determining the encryption method during the process of obtaining the secondary encrypted ciphertext is as follows: Define array a[] as an encryption method array, define M as the ASCII code of the second specific bit character of the key, define m as a positive integer less than M, and define Q{C, P(M, m), a[]} as a loop algorithm. The specific steps of the loop algorithm include: Determine if C is greater than 0. If C is not greater than 0, stop the loop and encrypt the encrypted ciphertext using the array of encryption methods. If C is greater than 0, continue execution. The value obtained by P(M, m) is placed into array a[]. If array a[] is empty, it is placed at the beginning of array a[]. If a[] is not empty, it is searched from the beginning of array a[] backwards until an empty space is found to store the new value. The second specific number is incremented by 1, the value of C is decremented by 1, and then the loop jumps back to the step of checking whether C is greater than 0. Based on the number sequence in the encryption method array determined by the loop algorithm, the corresponding encryption method is selected to encrypt the first-encrypted ciphertext twice in sequence to obtain the second-encrypted ciphertext.

4. The method for encrypting and transmitting information as described in claim 3, characterized in that: After the loop algorithm stops but before the first encrypted ciphertext is encrypted a second time, the following steps are also included: Define H as the ASCII code of the character at the third specific bit of the key corresponding to the encryption order, define h as the value that determines the encryption order, define the function R(H, 2) as the function that takes the remainder of H divided by 2, and h = R(H, 2), and determine whether to reverse the array a[] based on the value of h.

5. The method for encrypting and transmitting information as described in claim 1, characterized in that: In the process of obtaining the three-level encrypted ciphertext, the HMAC-SHA256 algorithm is used to calculate the secondary encrypted ciphertext to obtain the verification information. The verification information is divided into three segments, and the segmented verification information is inserted into the secondary encrypted ciphertext from the specific bit position of the fourth specific bit position of the key to obtain the tertiary encrypted ciphertext.

6. A decryption method for decrypting encrypted information generated by the method for encrypting and transmitting information according to any one of claims 1-5, comprising the following steps: Receive encrypted ciphertext three times; Verification information is extracted from the three encrypted ciphertexts to confirm that the three encrypted ciphertexts have not been tampered with, and then decryption is performed through the decryption process. Remove padding bytes to obtain plaintext.

7. The decryption method as described in claim 6, characterized in that: The specific method to confirm that the encrypted ciphertext has not been tampered with is as follows: The segmented verification information is extracted from the three encrypted ciphertexts. The verification information of the three encrypted ciphertexts is calculated using the decryption algorithm corresponding to the three encryption algorithms. The extracted verification information is compared with the calculated verification information. If it is confirmed that there is no error, it means that the three encrypted ciphertexts have not been tampered with.

8. The decryption method as described in claim 6, characterized in that: The decryption process is the inverse process of obtaining the secondary encrypted ciphertext and obtaining the primary encryption process.

Citation Information

Patent Citations

  • Novel symmetric key algorithm for high speed encryption

    CN106656475A

  • A data encryption method and decryption method based on a chaotic block encryption algorithm

    CN109861810A