Data encryption method and device, data decryption method and device, and electronic equipment

By encoding and dynamic insertion of encrypted data, combined with data format conversion, the effect of simplifying the encryption process and reducing the capacity of ciphertext data is achieved, and the existing encryption methods have high performance requirements for computing equipment and large ciphertext data capacity is solved. question.

CN114329536BActive Publication Date: 2025-02-18CHINA TELECOM CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111595177.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-23
Publication Date
2025-02-18
Estimated Expiration
2041-12-23

AI Technical Summary

Technical Problem

The existing encryption methods have high performance requirements for computing equipment and large ciphertext data capacity, which increases the burden on the database system.

Method used

By encoding the data to be encrypted, the first intermediate data is obtained, and the insertion data is calculated based on the flag data of the preset position, and the dynamic insertion process obtains the second intermediate data. Then, the second intermediate data is converted into the data format to obtain the ciphertext data, making its data format the same as the data to be encrypted, and the capacity of the ciphertext data is reduced.

Benefits of technology

The data encryption and decryption process is simplified, the capacity of ciphertext data is reduced, the performance requirements for computing device are reduced, and data security is improved through custom data format conversion methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114329536B_ABST
    Figure CN114329536B_ABST
Patent Text Reader

Abstract

The embodiments of the present disclosure disclose a data encryption method and device, a data decryption method and device, and an electronic device. The data encryption method provided by the embodiments of the present disclosure obtains first intermediate data by encoding data to be encrypted; obtains flag data corresponding to a preset position in the first intermediate data, and calculates the flag data to obtain insertion data; obtains second intermediate data according to the first intermediate data and the insertion data. The second intermediate data is obtained by dynamically inserting the first intermediate data through the insertion data, thereby increasing the difficulty of cracking the encryption method. Then, the ciphertext data is obtained by converting the data format of the second intermediate data, so that the data format of the obtained ciphertext data is the same as the data format of the data to be encrypted, thereby obtaining ciphertext data with a smaller capacity, reducing the burden on the data storage device that stores the ciphertext data.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] With the development of Internet technology, more and more information is available on the Internet. In order to prevent the information from being illegally obtained, the stored information is usually encrypted and stored to ensure the security of the data. In the data application system of the related technology, there are many ways to encrypt the stored information, for example, using the Advanced Encryption Standard (AES) and the Triple Data Encryption Standard (3DES) to encrypt it.

[0003] However, the above encryption method has high requirements on the performance of computing equipment, and the final ciphertext data capacity is large, which increases the burden on the database system.

[0004] Therefore, how to provide a data encryption method with a simple calculation method and a small final ciphertext capacity has become an urgent problem to be solved by technical personnel in this field. Summary of the invention

[0005] The present invention provides a data encryption method and device, a data decryption method and device, and an electronic device to simplify the data encryption and data decryption processes and reduce the ciphertext capacity.

[0006] According to a first aspect of an embodiment of the present disclosure, a data encryption method is provided, comprising: obtaining data to be encrypted, and encoding the data to be encrypted to obtain first intermediate data; obtaining flag data corresponding to a preset position in the first intermediate data, and calculating the flag data to obtain inserted data; obtaining second intermediate data based on the first intermediate data and the inserted data; performing data format conversion processing on the second intermediate data to obtain ciphertext data; wherein the data format of the ciphertext data is the same as the data format of the data to be encrypted.

[0007] In some embodiments, based on the aforementioned scheme, mark data corresponding to a preset position in the first intermediate data is obtained, and the mark data is calculated to obtain the insertion data, including: obtaining the insertion quantity and insertion position according to the mark data; generating a random number sequence according to the insertion quantity and insertion position; and obtaining the insertion data corresponding to each insertion position of the first intermediate data according to the random number sequence.

[0008] In some embodiments, based on the aforementioned scheme, the insertion quantity and insertion position are obtained according to the marker data, including: calculating the insertion quantity of the inserted data for the first intermediate data according to the data length of the marker data and the data length of the first intermediate data; and obtaining the insertion position of the inserted data for the first intermediate data according to the position information of the preset characters in the marker data in the marker data.

[0009] In some embodiments, based on the aforementioned scheme, a random number sequence is generated according to the number of insertions and the insertion position, including: obtaining the number of random numbers according to the number of insertions, and obtaining the random value corresponding to each random number according to the insertion position; obtaining a random number sequence according to the number of random numbers and the random value corresponding to each random number.

[0010] In some embodiments, based on the aforementioned scheme, the data to be encrypted is obtained, and the data to be encrypted is encoded to obtain first intermediate data, including: obtaining a binary expression sequence corresponding to the data to be encrypted; encoding the binary expression sequence according to a preset encoding algorithm to obtain a character expression sequence corresponding to the data to be encrypted, and using the character expression sequence as the first intermediate data.

[0011] In some embodiments, based on the aforementioned scheme, the second intermediate data is subjected to data format conversion processing to obtain ciphertext data, including: obtaining a data conversion mapping table that matches the data format of the data to be encrypted; wherein the data conversion mapping table is pre-set with a conversion relationship between the data format of the second intermediate data and the data format of the data to be encrypted; and the second intermediate data is subjected to data format conversion processing according to the data conversion mapping table to obtain ciphertext data.

[0012] According to the second aspect of the embodiment of the present disclosure, a data decryption method is provided, which includes: obtaining ciphertext data, and performing data format conversion processing on the ciphertext data to obtain third intermediate data; obtaining flag data corresponding to a preset position in the third intermediate data, and calculating the flag data to obtain insertion data; obtaining fourth intermediate data based on the third intermediate data and the insertion data; decoding the fourth intermediate data to obtain plaintext data; wherein the data format of the ciphertext data is the same as the data format of the plaintext data.

[0013] According to a third aspect of an embodiment of the present disclosure, a data encryption device is provided, comprising: an encryption conversion module, used to obtain data to be encrypted, and encode the data to be encrypted to obtain first intermediate data; an encryption data calculation module, used to obtain flag data corresponding to a preset position in the first intermediate data, and calculate the flag data to obtain insertion data; an encryption data insertion module, used to obtain second intermediate data according to the first intermediate data and the insertion data; a ciphertext generation module, used to perform data format conversion processing on the second intermediate data to obtain ciphertext data; wherein the data format of the ciphertext data is the same as the data format of the data to be encrypted.

[0014] According to a fourth aspect of an embodiment of the present disclosure, a data decryption device is provided, comprising: a decryption conversion module, used to obtain ciphertext data, and perform data format conversion processing on the ciphertext data to obtain third intermediate data; a decryption data calculation module, used to obtain flag data corresponding to a preset position in the third intermediate data, and calculate the flag data to obtain insertion data; a decryption data deletion module, used to obtain fourth intermediate data based on the third intermediate data and the insertion data; a plaintext data acquisition module, used to decode the fourth intermediate data to obtain plaintext data; wherein the data format of the ciphertext data is the same as the data format of the plaintext data.

[0015] According to a fifth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the program implements the data encryption method as described above, or implements the data decryption method as described above.

[0016] According to the sixth aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a memory and a processor; the memory is used to store a computer-executable program; the processor is used to call the computer-executable program to implement the data encryption method as described above, or to implement the data decryption method as described above.

[0017] The exemplary embodiments of the present disclosure have the following beneficial effects:

[0018] The data encryption method and device, data decryption method and device, and electronic device provided by the embodiments of the present disclosure obtain the data to be encrypted and encode the data to be encrypted to obtain the first intermediate data; obtain the flag data corresponding to the preset position in the first intermediate data, and calculate the flag data to obtain the insertion data; obtain the second intermediate data according to the first intermediate data and the insertion data. The second intermediate data is obtained by dynamically inserting the first intermediate data through the insertion data, thereby increasing the difficulty of cracking the encryption method. Then, the ciphertext data is obtained by performing a data format conversion process on the second intermediate data, so that the data format of the obtained ciphertext data is the same as the data format of the data to be encrypted, thereby obtaining ciphertext data with a smaller capacity, reducing the burden on the data storage device that stores the ciphertext data, and the information of the data to be encrypted can be disrupted through a customized data format conversion process to achieve protection of the data to be encrypted. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure, and together with the specification, are used to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0020] Figure 1 A flow chart showing a data encryption method in an embodiment of the present disclosure is shown;

[0021] Figure 2 A schematic diagram showing obtaining second intermediate data according to data to be encrypted in one embodiment of the present disclosure is shown;

[0022] Figure 3 A schematic diagram showing obtaining ciphertext data according to second intermediate data in one embodiment of the present disclosure is shown;

[0023] Figure 4 A data flow chart showing a data encryption method in an embodiment of the present disclosure is shown;

[0024] Figure 5 A flow chart showing a data decryption method in an embodiment of the present disclosure is shown;

[0025] Figure 6 A data flow chart showing a data decryption method in an embodiment of the present disclosure;

[0026] Figure 7 A schematic diagram showing the structure of a data encryption device in an embodiment of the present disclosure is shown;

[0027] Figure 8 A schematic diagram showing the structure of a data decryption device in an embodiment of the present disclosure is shown;

[0028] Fig. 9 A schematic diagram of the structure of an electronic device in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0029] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0030] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0031] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0032] It should also be noted that the "plurality" mentioned in this disclosure refers to two or more than two. "And / or" describes the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0033] Some embodiments of the present disclosure are described in detail below in conjunction with the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments may be combined with each other.

[0034] See also Figure 1 , Figure 1 This is a flow chart of the data encryption method in the embodiment of the present disclosure. Figure 1 , a data encryption method in an exemplary embodiment of the present disclosure is described.

[0035] Step S110: Obtain the data to be encrypted, and perform encoding processing on the data to be encrypted to obtain first intermediate data.

[0036] The data to be encrypted refers to a meaningful set of characters or bits, or information that can be obtained through a certain public encoding standard, that is, plaintext data before encryption. Encoding the data to be encrypted refers to the process of converting the data to be encrypted from one data format to another data format.

[0037] It is understandable that the data format of the data to be encrypted before encoding is different from the data format of the first intermediate data after encoding. For example, the data format of the data to be encrypted may be binary type, and the data format of the first intermediate data may be string type; or the data format of the data to be encrypted may be string type, and the data format of the first intermediate data may be binary type. The data format of the data to be encrypted and the data format of the first intermediate data may be flexibly set according to actual conditions, and the present disclosure does not limit this.

[0038] In some embodiments, data to be encrypted is obtained, and the data to be encrypted is encoded to obtain first intermediate data, including: obtaining a binary expression sequence corresponding to the data to be encrypted; encoding the binary expression sequence according to a preset encoding algorithm to obtain a character expression sequence corresponding to the data to be encrypted, and using the character expression sequence as the first intermediate data.

[0039] The data to be encrypted may be in a variety of data formats or a combination of a variety of data formats. Therefore, in order to facilitate calculation, the data to be encrypted may be converted into binary to obtain a binary expression sequence corresponding to the data to be encrypted. Binary refers to a number system with base 2 in mathematics and digital circuits. It is a binary system with base 2 representing the system, usually represented by two different symbols 0 and 1.

[0040] Exemplarily, a corresponding encoding algorithm can be selected according to the data format contained in the data to be encrypted, so as to convert the data to be encrypted whose data format is not binary into a binary expression sequence. For example, if the data to be encrypted is "staffWiFi", it means that it is all letter type, and the American Standard Code for Information Interchange (ASCII for short) can be directly used for data encoding. When the data to be sent is "staff123", it means that it includes letter type and number type, and UTF-8 can be used for data encoding. When the data to be sent is "staff123", it means that it includes Chinese type, and GBK can be used for data encoding.

[0041] Then, the binary expression sequence is encoded according to a preset encoding algorithm to obtain a character expression sequence corresponding to the data to be encrypted, that is, to obtain the first intermediate data. The disclosed embodiment takes the first intermediate data as a character expression sequence as an example for explanation. It can be understood that the data to be encrypted can also be converted into an expression sequence of other data formats to obtain the first intermediate data, and the disclosed embodiment does not limit this.

[0042] It should be noted that the encoding algorithm used in the present disclosure for encoding the encrypted data is a reversible algorithm, that is, the data obtained by the encoding process is the same as the data before the encoding process after decoding. For example, the encoding method used for encoding the encrypted data includes but is not limited to representing binary data based on 64 printable characters (base64).

[0043] Step S120: Obtain the marker data corresponding to the preset position in the first intermediate data, and calculate the marker data to obtain the insertion data.

[0044] The preset position may be a specific position set in advance by relevant technical personnel, such as the preset position may be the head position of the first intermediate data, the tail position of the first intermediate data, etc.; it may also be obtained by judging the first intermediate data or the data to be encrypted according to a preset judgment rule, for example, when the first character of the first intermediate data is a number, the corresponding preset position may be the head position of the first intermediate data; when the first character of the first intermediate data is a letter, the corresponding preset position may be the tail position of the first intermediate data.

[0045] The mark data may be original data at a preset position in the first intermediate data, or may be a data value obtained by converting the original data at a preset position in the first intermediate data.

[0046] For example, see Figure 2 , the data to be encrypted is " / <.*> / ", and the data to be encrypted is encoded according to base64, and the first intermediate data obtained is "LzwuKj4vCg==". Among them, the preset position in the first intermediate data is the header position of the first intermediate data, and therefore, the original data corresponding to the header position of the first intermediate data is "L". Further, the original data "L" is converted to ASCII, and the obtained flag data is "01001100". It can be understood that the original data "L" can also be converted into flag data through other conversion methods, and the present disclosure does not limit this.

[0047] In some embodiments, marker data corresponding to a preset position in the first intermediate data is obtained, and the marker data is calculated to obtain insertion data, including: obtaining the insertion quantity and insertion position based on the marker data; generating a random number sequence based on the insertion quantity and insertion position; and obtaining the insertion data corresponding to each insertion position of the first intermediate data based on the random number sequence.

[0048] The inserted data is calculated according to the flag data and the preset inserted data calculation rules, so as to increase the difficulty of deciphering the ciphertext by inserting the data, thereby improving data security.

[0049] Exemplarily, the insertion quantity and insertion position are obtained according to the flag data, the insertion quantity refers to the quantity information of the inserted data, and the insertion position refers to the position information of each inserted data for the first intermediate data. Then, a corresponding random number sequence is generated according to the insertion quantity and the insertion position, the random number sequence includes multiple random numbers, each random number corresponds to the inserted data of each insertion position of the first intermediate data.

[0050] For example, Figure 2As shown, the first intermediate data is "LzwuKj4vCg==", and the mark data obtained according to the original data corresponding to the header position of the first intermediate data is "01001100". The insertion number can be obtained according to the number of "1" in the mark data, that is, the insertion number is 3.

[0051] Furthermore, the insertion position can be calculated according to formula (1):

[0052] S i =j*Len(RC) / Len(AC) (1)

[0053] Among them, S i It refers to the insertion position of the first intermediate data corresponding to the i-th random number in the random number sequence, j refers to the position of "1" in the mark data, Len(RC) refers to the data length of the first intermediate data, and Len(AC) refers to the data length of the mark data.

[0054] Therefore, through calculation, it is obtained that the insertion position of the first intermediate data corresponding to the first random number in the random number sequence is the second position, the insertion position of the first intermediate data corresponding to the second random number in the random number sequence is the fifth position, and the insertion position of the first intermediate data corresponding to the third random number in the random number sequence is the sixth position.

[0055] In some embodiments, a corresponding random number sequence is generated based on the number of insertions and the insertion positions, including: obtaining the number of random numbers based on the number of insertions, and obtaining the random value corresponding to each random number based on the insertion position; and obtaining a random number sequence based on the number of random numbers and the random value corresponding to each random number.

[0056] For example, if the number of insertions is 3, the number of random numbers obtained is 3, and then the random value corresponding to each random number is obtained according to the insertion position, and the generated random number sequence is (a1, a2, a3). Among them, the insertion position corresponding to the first random number a1 in the random number sequence is the second position of the first intermediate data, the insertion position corresponding to the second random number a2 in the random number sequence is the fifth position of the first intermediate data, and the insertion position corresponding to the third random number a3 in the random number sequence is the sixth position of the first intermediate data.

[0057] It should be noted that other preset insertion data calculation rules may also be used to calculate the insertion data. For example, the insertion quantity may be obtained according to the number of "0" in the marker data, the insertion quantity may be obtained according to the difference between the data length of the first intermediate data and the data length of the marker data, the insertion position of the first intermediate data may be obtained according to the position of "0" in the marker data, etc. The method for obtaining the insertion data may be flexibly selected according to the actual situation, and the present disclosure does not limit this.

[0058] It is understandable that the preset insertion data calculation rule and the method for obtaining the mark data are only known by the encryption device and the decryption device.

[0059] Step S130: Obtain second intermediate data according to the first intermediate data and the insertion data.

[0060] A data insertion operation is performed on the first intermediate data according to the insertion data to obtain second intermediate data.

[0061] In some embodiments, the inserted data is a random number sequence. Figure 2 As shown, the first intermediate data is "LzwuKj4vCg==", and the random number sequence is (a1, a2, a3), wherein the insertion position corresponding to a1 is the second bit of the first intermediate data, the insertion position corresponding to a2 is the fifth bit of the first intermediate data, and the insertion position corresponding to a3 is the sixth bit of the first intermediate data. According to the random number sequence and the insertion position corresponding to each random number in the random number sequence, a data insertion operation is performed on the first intermediate data to obtain the second intermediate data "Lza1wuKa2ja34vCg==".

[0062] Among them, since the inserted data is a randomly generated random number, and the insertion position of each random number in the inserted data is dynamically calculated, the difficulty of cracking is increased in view of the randomness of the random number itself and the dynamic selection of the insertion position.

[0063] Step S140: Perform data format conversion processing on the second intermediate data to obtain ciphertext data; wherein the data format of the ciphertext data is the same as the data format of the data to be encrypted.

[0064] The data format conversion process is used to convert the data format of the second intermediate data into the data format of the data to be encrypted. Therefore, the data format of the ciphertext data obtained by the data format conversion process is the same as the data format of the data to be encrypted.

[0065] By using ciphertext data with the same data format as the data to be encrypted, ciphertext data with a smaller capacity can be obtained, so as to avoid the ciphertext data from expanding too much relative to the data to be encrypted, so as to reduce the burden on the data storage device storing the ciphertext data while protecting the data to be encrypted. The expansion degree refers to the multiple relationship between the data capacity of the ciphertext data and the data capacity of the data to be encrypted. The larger the multiple of the data capacity of the ciphertext data relative to the data capacity of the data to be encrypted, the greater the expansion degree.

[0066] In some embodiments, data format conversion is performed on the second intermediate data to obtain ciphertext data, including: obtaining a data conversion mapping table that matches the data format of the data to be encrypted; wherein the data conversion mapping table is preset with a conversion relationship between the data format of the second intermediate data and the data format of the data to be encrypted; and data format conversion is performed on the second intermediate data according to the data conversion mapping table to obtain ciphertext data.

[0067] The data conversion mapping table is set in advance by relevant technical personnel, in which the conversion relationship between the data format of the second intermediate data and the data format of the data to be encrypted is preset.

[0068] Among them, the data to be encrypted in different data formats corresponds to different data conversion mapping tables. Therefore, it is necessary to obtain a data conversion mapping table that matches the data format of the data to be encrypted, so as to convert each character in the second intermediate data according to the data conversion mapping table, and then obtain the converted ciphertext data.

[0069] It can be understood that the data conversion mapping table is only known by the encryption device and the decryption device.

[0070] For example, see Figure 3 , the second intermediate data is "Lza1wuKa2ja34vCg==", each character in the second intermediate data is converted into a binary expression sequence corresponding to the character, and then the data conversion mapping table is queried according to the binary expression sequence corresponding to the character to obtain the ciphertext expression corresponding to each character in the second intermediate data, and then the ciphertext data is obtained according to the ciphertext expression corresponding to each character. For example, the binary expression sequence of the character "L" in the second intermediate data is "01001100", and the ciphertext expression of the character "L" in the second intermediate data is obtained by querying the data conversion mapping table according to "01001100" as " / [". All characters in the second intermediate data are converted through the data conversion mapping table, and the ciphertext data obtained is " / [* / tsS+w / na / / Cxz\vln".

[0071] See also Figure 4 , Figure 4 FIG. 1 is a data flow chart of a data encryption method in another embodiment of the present disclosure. Figure 4 As shown, the data to be encrypted is encoded to obtain first intermediate data, and the flag data is obtained according to the data value of the preset position in the first intermediate data. Then, the insertion data is calculated according to the flag data, and the first intermediate data is subjected to data insertion processing according to the insertion data to obtain second intermediate data. Further, according to the second intermediate data and the preset data conversion mapping table, data conversion processing is performed to obtain ciphertext data with the same data format as the data to be encrypted.

[0072] The data encryption method provided by the embodiment of the present disclosure obtains the data to be encrypted and performs encoding processing on the data to be encrypted to obtain the first intermediate data; obtains the flag data corresponding to the preset position in the first intermediate data, and calculates the flag data to obtain the insertion data; obtains the second intermediate data according to the first intermediate data and the insertion data. The second intermediate data is obtained by dynamically inserting the first intermediate data through the insertion data, thereby increasing the difficulty of cracking the encryption method. Then, the ciphertext data is obtained by performing data format conversion processing on the second intermediate data, so that the data format of the obtained ciphertext data is the same as the data format of the data to be encrypted, thereby obtaining ciphertext data with a smaller capacity, reducing the burden on the data storage device that stores the ciphertext data, and the information of the data to be encrypted can be disrupted through a customized data format conversion processing method to achieve protection of the data to be encrypted.

[0073] See also Figure 5 , Figure 5 This is a flow chart of the data decryption method in the embodiment of the present disclosure. Figure 5 , a data decryption method in an exemplary embodiment of the present disclosure is described.

[0074] Step S510: Acquire ciphertext data, and perform data format conversion processing on the ciphertext data to obtain third intermediate data.

[0075] Among them, ciphertext data refers to characters or bit sets that cannot be directly understood. It is the data obtained by scrambling the information in the plaintext data, but the scrambled information can be restored through algorithms.

[0076] It can be understood that the third intermediate data in step S510 of this embodiment is equivalent to the second intermediate data in step S140.

[0077] Exemplarily, a data conversion mapping table matching the data format of the ciphertext data is obtained; wherein the data conversion mapping table is preset with a conversion relationship between the data format of the ciphertext data and the data format of the third intermediate data; the ciphertext data is subjected to data format conversion processing according to the data conversion mapping table to obtain the third intermediate data.

[0078] The data conversion mapping table is set in advance by relevant technical personnel, in which the conversion relationship between the data format of the third intermediate data and the data format of the ciphertext data is preset.

[0079] For example, see Figure 6, the ciphertext data is " / [* / tsS+w / na / / Cxz\vln", all characters in the ciphertext data are converted according to the data conversion mapping table to obtain the binary expression sequence corresponding to each character in the ciphertext data. Then, according to the binary expression sequence corresponding to each character in the ciphertext data, the third intermediate data expression corresponding to each character in the ciphertext data is obtained, and the third intermediate data is obtained according to the third intermediate data expression corresponding to each character. For example, the binary expression sequence corresponding to the character " / [" in the ciphertext data is "01001100", and then the binary expression sequence "01001100" is converted to ASCII to obtain the third intermediate data expression "L". All characters in the ciphertext data are converted through the data conversion mapping table, and the third intermediate data finally obtained is "Lza1wuKa2ja34vCg==".

[0080] Step S520: Obtain the mark data corresponding to the preset position in the third intermediate data, and calculate the mark data to obtain the insertion data.

[0081] It should be noted that the preset position of the third intermediate data in step S520 is the same as the data value corresponding to the preset position of the first intermediate data in step S120.

[0082] It should be noted that the method of calculating the insertion data according to the mark data is the same as the method in step S120.

[0083] In some embodiments, the preset position in the third intermediate data is a header position to simplify the calculation process of encryption and decryption.

[0084] For example, the third intermediate data is "Lza1wuKa2ja34vCg==", and the original data corresponding to the header position of the third intermediate data is "L". Further, the original data "L" is converted to ASCII, and the flag data is "01001100". Then, the inserted data calculated according to the flag data is the data value "1" after the second character in the third intermediate data, the data value "2" after the sixth character in the third intermediate data, and the data value "3" after the eighth character in the third intermediate data.

[0085] Step S530: Obtain fourth intermediate data according to the third intermediate data and the inserted data.

[0086] A data deletion operation is performed on the third intermediate data according to the inserted data to obtain fourth intermediate data.

[0087] It can be understood that the fourth intermediate data in step S530 of this embodiment is equivalent to the first intermediate data in step S110.

[0088] For example, the third intermediate data is "Lza1wuKa2ja34vCg==", and the inserted data includes the data value "1" after the second character in the third intermediate data, the data value "2" after the sixth character in the third intermediate data, and the data value "3" after the eighth character in the third intermediate data. The third data is deleted according to the inserted data, and the fourth intermediate data obtained is "LzwuKj4vCg==".

[0089] Step S540: Decode the fourth intermediate data to obtain plaintext data; wherein the data format of the ciphertext data is the same as the data format of the plaintext data.

[0090] The decoding process is the reverse process of the encoding process.

[0091] It should be noted that the fourth intermediate data is decoded using a decoding algorithm corresponding to the encoding algorithm in the encoding process in step S110 to obtain plaintext data.

[0092] For example, the fourth intermediate data “LzwuKj4vCg==” is decoded, and the obtained plain text data is “ / <.*> / ”.

[0093] The data decryption method provided by the embodiment of the present disclosure obtains ciphertext data and performs data format conversion processing on the ciphertext data to obtain third intermediate data; obtains flag data corresponding to a preset position in the third intermediate data, calculates the flag data to obtain insertion data; obtains fourth intermediate data based on the third intermediate data and the insertion data; and decodes the fourth intermediate data to obtain plaintext data; wherein the data format of the ciphertext data is the same as the data format of the plaintext data. By using ciphertext data with the same data format as the data to be encrypted, the capacity of the ciphertext data can be reduced, and the burden on the data storage device storing the ciphertext data can be reduced. By calculating the intermediate data to obtain the plaintext data, the decryption process is simplified and the computing performance requirements of the decryption device are reduced while ensuring data security.

[0094] Furthermore, this exemplary embodiment also provides a data encryption device 700. Figure 7 As shown, the data encryption device 700 includes: an encryption conversion module 710, an encryption data calculation module 720, an encryption data insertion module 730, and a ciphertext generation module 740.

[0095] The encryption conversion module 710 is used to obtain the data to be encrypted, and perform encoding processing on the data to be encrypted to obtain first intermediate data.

[0096] The encrypted data calculation module 720 is used to obtain the mark data corresponding to the preset position in the first intermediate data, and calculate the mark data to obtain the insertion data.

[0097] The encrypted data insertion module 730 is used to obtain second intermediate data according to the first intermediate data and the insertion data.

[0098] The ciphertext generation module 740 is used to perform data format conversion processing on the second intermediate data to obtain ciphertext data; wherein the data format of the ciphertext data is the same as the data format of the data to be encrypted.

[0099] In some implementations, based on the above solution, the encrypted data calculation module 720 includes a quantity and position calculation module, a random number generation module, and an insertion data acquisition module:

[0100] The quantity and position calculation module is used to obtain the insertion quantity and insertion position according to the mark data;

[0101] The random number generation module is used to generate a random number sequence according to the insertion quantity and insertion position;

[0102] The insertion data acquisition module is used to obtain the insertion data corresponding to each insertion position of the first intermediate data according to the random number sequence.

[0103] In some implementations, based on the above solution, the quantity and position calculation module includes a quantity calculation module and a position calculation module:

[0104] The quantity calculation module is used to calculate the insertion quantity of the inserted data for the first intermediate data according to the data length of the flag data and the data length of the first intermediate data;

[0105] The position calculation module is used to obtain the insertion position of the inserting data with respect to the first intermediate data according to the position information of the preset character in the mark data in the mark data.

[0106] In some embodiments, based on the above scheme, the random number generation module includes a single random number generation module and a sequence generation module:

[0107] The single random number generation module is used to obtain the number of random numbers according to the number of insertions, and to obtain the random value corresponding to each random number according to the insertion position;

[0108] The sequence generation module is used to obtain a random number sequence according to the number of random numbers and the random value corresponding to each random number.

[0109] In some implementations, based on the above solution, the encryption conversion module 710 includes a binary conversion module and a character conversion module:

[0110] The binary conversion module is used to obtain the binary expression sequence corresponding to the data to be encrypted;

[0111] The character conversion module is used to encode the binary expression sequence according to a preset encoding algorithm to obtain a character expression sequence corresponding to the data to be encrypted, and use the character expression sequence as the first intermediate data.

[0112] In some embodiments, based on the above scheme, the ciphertext generation module 740 includes a mapping table acquisition module and an obfuscation module:

[0113] The mapping table acquisition module is used to acquire a data conversion mapping table that matches the data format of the data to be encrypted; wherein the data conversion mapping table is preset with a conversion relationship between the data format of the second intermediate data and the data format of the data to be encrypted;

[0114] The obfuscation module is used to perform data format conversion processing on the second intermediate data according to the data conversion mapping table to obtain ciphertext data.

[0115] Furthermore, this exemplary embodiment also provides another data decryption device 800. Figure 8 As shown, the data decryption device 800 includes: a decryption conversion module 810, a decryption data calculation module 820, a decryption data deletion module 830 and a plaintext data acquisition module 840.

[0116] The decryption conversion module 810 is used to obtain ciphertext data and perform data format conversion processing on the ciphertext data to obtain third intermediate data.

[0117] The decrypted data calculation module 820 is used to obtain the mark data corresponding to the preset position in the third intermediate data, and calculate the mark data to obtain the insertion data.

[0118] The decrypted data deletion module 830 is used to obtain fourth intermediate data according to the third intermediate data and the inserted data.

[0119] The plaintext data acquisition module 840 is used to decode the fourth intermediate data to obtain plaintext data; wherein the data format of the ciphertext data is the same as the data format of the plaintext data.

[0120] It should be noted that the device provided in the above embodiment and the method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment and will not be repeated here.

[0121] It should be noted that although several modules or units of the data encryption device and the data decryption device are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0122] In addition, in an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above-mentioned data encryption method and data decryption method is also provided.

[0123] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware embodiments, complete software embodiments (including firmware, microcode, etc.), or embodiments combining hardware and software aspects, which may be collectively referred to herein as "circuits", "modules" or "systems".

[0124] Refer to the following Fig. 9 hereinafter describes an electronic device 900 according to such an embodiment of the present disclosure. Fig. 9 The electronic device 900 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0125] like Fig. 9 As shown, the electronic device 900 is in the form of a general computing device. The components of the electronic device 900 may include, but are not limited to: the at least one processing unit 910, the at least one storage unit 920, a bus 930 connecting different system components (including the storage unit 920 and the processing unit 910), and a display unit 940.

[0126] The storage unit stores program codes, which can be executed by the processing unit 910, so that the processing unit 910 executes the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification.

[0127] The storage unit 920 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 921 and / or a cache memory unit 922 , and may further include a read-only memory unit (ROM) 923 .

[0128] The storage unit 920 may also include a program / utility 924 having a set (at least one) of program modules 925, such program modules 925 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0129] Bus 930 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0130] The electronic device 900 may also communicate with one or more external devices 970 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 900, and / or communicate with any device that enables the electronic device 900 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 950. Furthermore, the electronic device 900 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 960. As shown, the network adapter 960 communicates with other modules of the electronic device 900 via a bus 930. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0131] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiment of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiment of the present disclosure.

[0132] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible embodiments, various aspects of the present disclosure can also be implemented in the form of a program product, which includes a program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present disclosure described in the above "Exemplary Method" section of the present specification.

[0133] The exemplary embodiments of the present disclosure are specifically shown and described above. It is understood that the present disclosure is not limited to the detailed structures, configurations or implementations described herein; on the contrary, the present disclosure is intended to cover various modifications and equivalent configurations included in the spirit and scope of the appended claims.

Claims

1. A data encryption method, characterized in that: The method comprises: Acquire data to be encrypted, and perform encoding processing on the data to be encrypted to obtain first intermediate data; Obtaining the mark data corresponding to the preset position in the first intermediate data, and calculating the mark data to obtain the insertion data; wherein calculating the mark data to obtain the insertion data includes: calculating the number of insertions of the insertion data for the first intermediate data according to the data length of the mark data and the data length of the first intermediate data; and obtaining the insertion position of the insertion data for the first intermediate data according to the position information of the preset character in the mark data in the mark data; generating a random number sequence according to the insertion number and the insertion position; and obtaining the insertion data corresponding to each insertion position of the first intermediate data according to the random number sequence; Obtaining second intermediate data according to the first intermediate data and the inserted data; The second intermediate data is processed for data format conversion to obtain ciphertext data; wherein the data format of the ciphertext data is the same as the data format of the data to be encrypted.

2. The method according to claim 1, characterized in that The generating of a random number sequence according to the insertion quantity and the insertion position comprises: Obtaining the number of random numbers according to the insertion number, and obtaining the random value corresponding to each random number according to the insertion position; The random number sequence is obtained according to the number of the random numbers and the random value corresponding to each random number.

3. The method according to any one of claims 1 to 2, characterized in that: The step of obtaining the data to be encrypted and encoding the data to be encrypted to obtain first intermediate data includes: Obtaining a binary expression sequence corresponding to the data to be encrypted; The binary expression sequence is encoded according to a preset encoding algorithm to obtain a character expression sequence corresponding to the data to be encrypted, and the character expression sequence is used as the first intermediate data.

4. The method according to any one of claims 1 to 2, characterized in that: The performing data format conversion processing on the second intermediate data to obtain ciphertext data includes: Acquire a data conversion mapping table that matches the data format of the data to be encrypted; wherein the data conversion mapping table is preset with a conversion relationship between the data format of the second intermediate data and the data format of the data to be encrypted; The second intermediate data is processed by data format conversion according to the data conversion mapping table to obtain the ciphertext data.

5. A data decryption method, characterized in that: The method comprises: Acquire ciphertext data, and perform data format conversion processing on the ciphertext data to obtain third intermediate data; Obtaining the mark data corresponding to the preset position in the third intermediate data, and calculating the mark data to obtain the insertion data; wherein calculating the mark data to obtain the insertion data comprises: calculating the number of insertions of the insertion data for the third intermediate data according to the data length of the mark data and the data length of the third intermediate data; and obtaining the insertion position of the insertion data for the third intermediate data according to the position information of the preset character in the mark data in the mark data; generating a random number sequence according to the insertion number and the insertion position; and obtaining the insertion data corresponding to each insertion position of the third intermediate data according to the random number sequence; Obtaining fourth intermediate data according to the third intermediate data and the inserted data; The fourth intermediate data is decoded to obtain plaintext data; wherein the data format of the ciphertext data is the same as the data format of the plaintext data.

6. A data encryption device, characterized in that: include: The encryption conversion module is used to obtain the data to be encrypted and perform encoding processing on the data to be encrypted to obtain first intermediate data; The encrypted data calculation module is used to obtain the mark data corresponding to the preset position in the first intermediate data, and calculate the mark data to obtain the insertion data; wherein, calculating the mark data to obtain the insertion data includes: calculating the number of insertions of the insertion data for the first intermediate data according to the data length of the mark data and the data length of the first intermediate data; and obtaining the insertion position of the insertion data for the first intermediate data according to the position information of the preset character in the mark data in the mark data; generating a random number sequence according to the insertion number and the insertion position; and obtaining the insertion data corresponding to each insertion position of the first intermediate data according to the random number sequence; An encrypted data insertion module, used to obtain second intermediate data according to the first intermediate data and the insertion data; The ciphertext generation module is used to perform data format conversion processing on the second intermediate data to obtain ciphertext data; wherein the data format of the ciphertext data is the same as the data format of the data to be encrypted.

7. A data decryption device, characterized in that: include: A decryption conversion module, used to obtain ciphertext data and perform data format conversion processing on the ciphertext data to obtain third intermediate data; A decrypted data calculation module is used to obtain the mark data corresponding to the preset position in the third intermediate data, and calculate the mark data to obtain the insertion data; wherein, calculating the mark data to obtain the insertion data includes: calculating the insertion quantity of the insertion data for the third intermediate data according to the data length of the mark data and the data length of the third intermediate data; and obtaining the insertion position of the insertion data for the third intermediate data according to the position information of the preset character in the mark data in the mark data; generating a random number sequence according to the insertion quantity and the insertion position; and obtaining the insertion data corresponding to each insertion position of the third intermediate data according to the random number sequence; A decrypted data deletion module, used to obtain fourth intermediate data according to the third intermediate data and the inserted data; A plaintext data acquisition module is used to decode the fourth intermediate data to obtain plaintext data; wherein the data format of the ciphertext data is the same as the data format of the plaintext data.

8. An electronic device, characterized in that: include: Memory and processor; The memory is used to store computer executable programs; The processor is used to call the computer executable program to implement the data encryption method as described in any one of claims 1 to 4, or to implement the data decryption method as described in claim 5.

Citation Information

Patent Citations

  • Encryption transmission algorithm based on BASE64

    CN111769836A

  • Apparatus and method for transmitting encrypted content and and record media recoded program realizing the same

    KR1020090017055A