CN111611595A - Data encryption method and device - Google Patents

Data encryption method and device Download PDF

Info

Publication number
CN111611595A
CN111611595A CN202010251449.0A CN202010251449A CN111611595A CN 111611595 A CN111611595 A CN 111611595A CN 202010251449 A CN202010251449 A CN 202010251449A CN 111611595 A CN111611595 A CN 111611595A
Authority
CN
China
Prior art keywords
data
length
encrypted
comprehensive
integer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010251449.0A
Other languages
Chinese (zh)
Other versions
CN111611595B (en
Inventor
周亚桥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202010251449.0A priority Critical patent/CN111611595B/en
Publication of CN111611595A publication Critical patent/CN111611595A/en
Application granted granted Critical
Publication of CN111611595B publication Critical patent/CN111611595B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Storage Device Security (AREA)

Abstract

A data encryption method and device relate to the field of data encryption, and the method comprises the following steps: encrypting data to be encrypted by using a secret key to obtain initial encrypted data; generating first data according to a preset data transformation rule and the initial encrypted data, wherein the evolution result of the data length of the first data is an integer; performing nonlinear two-dimensional conversion on the first data; and carrying out nonlinear one-dimensional conversion on the first data after the nonlinear two-dimensional conversion to obtain final encrypted data. The method and the device improve the complexity of data encryption, prevent the encrypted data from being cracked, and improve the safety of the data.

Description

Data encryption method and device
Technical Field
The present application relates to the field of data encryption, and in particular, to a data encryption method and apparatus.
Background
A general company generates a lot of data in the operation process, and huge economic losses are brought to the company if the data are leaked. For example, the source code may be compiled into a byte code file, and when the interpreter runs, the server reads the byte code file and performs corresponding operations according to byte instructions in the byte code file. That is, the bytecode file can be interpreted to run even without the source code program. The consequence of this is that if the bytecode leaks, it is easily reverse compiled into the source code, which has a safety hazard.
Disclosure of Invention
In order to solve the technical problem or at least partially solve the technical problem, the present application provides a data encryption method and apparatus.
In a first aspect, the present application provides a data encryption method, including:
encrypting data to be encrypted by using a secret key to obtain initial encrypted data;
generating first data according to a preset data transformation rule and the initial encrypted data, wherein the evolution result of the data length of the first data is an integer;
performing nonlinear two-dimensional conversion on the first data;
and carrying out nonlinear one-dimensional conversion on the first data after the nonlinear two-dimensional conversion to obtain final encrypted data.
Optionally, the generating first data according to a preset data transformation rule and the initial encrypted data includes:
carrying out length transformation on the initial encrypted data to obtain comprehensive data;
determining the comprehensive data length of the comprehensive data, and judging whether the evolution result of the comprehensive data length is an integer;
if the evolution result of the length of the integrated data is not an integer, generating additional integrated data based on the integrated data, and taking the additional integrated data as the first data, wherein the evolution result of the length of the additional integrated data is an integer;
and if the evolution result of the length of the comprehensive data is an integer, taking the comprehensive data as the first data.
Optionally, the length transforming the initial encrypted data to obtain the comprehensive data includes:
determining a data length value of the initial encrypted data;
and adding second data after the initial encrypted data to obtain comprehensive data, wherein the second data is the data length value of the initial encrypted data.
Optionally, the generating additional integrated data based on the integrated data includes:
determining a minimum numerical value which is larger than the length of the comprehensive data and the evolution result of which is an integer;
calculating the difference between the minimum value and the length of the comprehensive data;
acquiring random data with the data length being the difference value;
inserting the random data between the initial encrypted data and the second data to generate additional integrated data.
Optionally, the performing nonlinear two-dimensional conversion on the first data includes:
arranging the first data into a square matrix.
Optionally, the performing nonlinear one-dimensional conversion on the first data after the nonlinear two-dimensional conversion to obtain final encrypted data includes:
and serializing the square matrix through a Hilbert curve to obtain final encrypted data.
Optionally, the method further includes:
performing nonlinear two-dimensional conversion on the final encrypted data;
performing nonlinear one-dimensional conversion on the final encrypted data after the nonlinear two-dimensional conversion to obtain the first data;
generating the initial encrypted data according to the first data and a preset data transformation inverse rule;
and decrypting the initial encrypted data to obtain the data to be encrypted.
In a second aspect, the present application provides a data encryption apparatus, the apparatus comprising:
the encryption module is used for encrypting the data to be encrypted through the secret key to obtain initial encrypted data;
the first generation module is used for generating first data according to a preset data transformation rule and the initial encrypted data, wherein the evolution result of the data length of the first data is an integer;
the first conversion module is used for carrying out nonlinear two-dimensional conversion on the first data;
and the second conversion module is used for carrying out nonlinear one-dimensional conversion on the first data after the nonlinear two-dimensional conversion to obtain final encrypted data.
Optionally, the first generating module includes:
the transformation unit is used for carrying out length transformation on the initial encrypted data to obtain comprehensive data;
the judging unit is used for determining the comprehensive data length of the comprehensive data and judging whether the evolution result of the comprehensive data length is an integer;
a first generating unit, configured to generate additional integrated data based on the integrated data if an evolution result of the data length of the integrated data is not an integer, and use the additional integrated data as the first data, where the evolution result of the data length of the additional integrated data is an integer;
and a second generating unit, configured to use the integrated data as the first data if an evolution result of the length of the integrated data is an integer.
Optionally, the transformation unit includes:
a first determining subunit, configured to determine a data length value of the initial encrypted data;
and the adding subunit is used for adding second data after the initial encrypted data to obtain comprehensive data, wherein the second data is a data length value of the initial encrypted data.
Optionally, the first generating unit includes:
the second determining subunit is used for determining a minimum numerical value which is larger than the length of the comprehensive data and the evolution result of which is an integer;
the calculating subunit is used for calculating the difference value between the minimum value and the comprehensive data length;
the acquiring subunit is used for acquiring random data with the data length being the difference value;
and the inserting subunit is used for inserting the random data between the initial encrypted data and the second data to generate additional comprehensive data.
Optionally, the first conversion module includes:
and the arrangement unit is used for arranging the first data into a square matrix.
Optionally, the second conversion module includes:
and the serialization unit is used for serializing the square matrix through a Hilbert curve to obtain final encrypted data.
Optionally, the apparatus further comprises:
the third conversion module is used for carrying out nonlinear two-dimensional conversion on the final encrypted data;
the fourth conversion module is used for carrying out nonlinear one-dimensional conversion on the final encrypted data after the nonlinear two-dimensional conversion to obtain the first data;
the second generation module is used for generating the initial encrypted data according to the first data and a preset data transformation inverse rule;
and the decryption module is used for decrypting the initial encrypted data to obtain the data to be encrypted.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages:
the embodiment of the application provides a data encryption method, the data to be encrypted is encrypted, nonlinear transformation between one dimension and two dimensions is carried out, the data sequence is disordered, the complexity of data encryption is improved, meanwhile, random data with variable data length are added into the data, the complexity of data encryption is improved, the encrypted data are prevented from being cracked, and the safety of the data is improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a flowchart of a data encryption method according to an embodiment of the present application;
FIG. 2 is a flow chart of a method for generating first data according to an embodiment of the present disclosure;
FIG. 3 is a flow chart of a method for generating additional synthetic data according to an embodiment of the present disclosure;
fig. 4 is a flowchart of a method for encrypting data according to an embodiment of the present application;
fig. 5 is a schematic diagram of a data encryption apparatus according to an embodiment of the present application;
fig. 6 is a schematic view of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Fig. 1 is a data encryption method provided in this embodiment, which may be applied to a server to increase complexity of data in an encryption process, and includes the following specific steps:
step 101: and encrypting the data to be encrypted by the secret key to obtain initial encrypted data.
In the embodiment of the application, the server initially encrypts the data to be encrypted through the key, wherein the data to be encrypted can be byte code data. Specifically, the initial encryption may include various ways, such as that the server exchanges the positions of characters in the data to be encrypted through the key, or, in the case that the data to be encrypted is a number, the server adds a preset value to each number in the data to be encrypted through the key, so that the number becomes a new number. The present application does not limit the specific manner of initial encryption. And the server takes the encrypted data to be encrypted as initial encrypted data, and the length of the character string of the initial encrypted data is consistent with that of the data to be encrypted.
For example, if the data to be encrypted is abcd, the initial encryption scrambles the position of the character of the data to be encrypted through the key to obtain initial encryption data bcea. If the data to be encrypted is 4568, the initial encryption adds a preset value of 1 to each digit in the data to be encrypted through the key, and initial encrypted data 5679 is obtained.
Step 102: and generating first data according to a preset data transformation rule and the initial encrypted data.
Wherein the root result of the data length of the first data is an integer.
In the embodiment of the application, after the server obtains the initial encrypted data, the server generates first data according to a preset data transformation rule and the initial encrypted data, wherein the evolution result of the data length of the first data is an integer, and the preset data transformation rule is used for increasing the data length of the initial encrypted data, so that the evolution result of the increased data length is an integer.
In one implementation, the server may determine whether an evolution result of the data length of the initial encrypted data is an integer, and if the evolution result of the data length of the initial encrypted data is an integer, take the initial encrypted data as the first data; if the evolution result of the data length of the initial encrypted data is not an integer, determining a minimum value which is greater than the initial encrypted data length and the evolution result of which is the integer, calculating a difference value between the minimum value and the initial encrypted data length, and setting a preset value with the value length being the difference value behind the initial encrypted data to generate first data. And the last value in the preset values is the same as the value of the initial encrypted data length.
For example, if the initial encrypted data is bcda12358, the initial encrypted data length is 9, and the root result is an integer of 3, then the server takes bcda12358 as the first data.
If the initial encrypted data is bcda, the initial encrypted data length is 4, and the derivation result is not an integer, the server determines that the minimum value greater than 4 and the derivation result is an integer is 9, and the server calculates that the difference between 9 and 4 is 5, and then the server sets a preset value with a value length of 5 and a last value of 4 after bcda, where the preset value may be 12344 or 65984.
In addition, there may be other implementation manners for generating the first data according to the preset data transformation rule and the initial encrypted data, and the detailed description will be given later in the specific process.
Step 103: and performing nonlinear two-dimensional conversion on the first data.
In the embodiment of the application, the server performs nonlinear two-dimensional conversion on the first data, so that the arrangement mode of each character in the first data can be disturbed.
Optionally, the process of performing nonlinear two-dimensional conversion on the first data is as follows: the first data is arranged in a square matrix.
In the embodiment of the present application, since the root result of the data length of the first data is an integer, the first data may be arranged in a square matrix.
For example, the data length of the first data is 9, and the square root result 3 of 9 is an integer, so the first data is arranged into a 3 × 3 matrix.
Step 104: and carrying out nonlinear one-dimensional conversion on the first data after the nonlinear two-dimensional conversion to obtain final encrypted data.
In the embodiment of the application, the server performs nonlinear one-dimensional conversion on the first data after the nonlinear two-dimensional conversion, so that the final encrypted data is still one-dimensional data, and a worker can store the one-dimensional final encrypted data conveniently.
Optionally, the process of performing nonlinear one-dimensional conversion on the first data after the nonlinear two-dimensional conversion is as follows: the square matrix is serialized by a hilbert curve.
In this embodiment, the server serializes the first data arranged in a square matrix by using a hilbert curve to obtain final encrypted data.
The server performs nonlinear one-dimensional conversion on the first data first and then performs nonlinear two-dimensional conversion, so that the sequence of the first data is disturbed, and the safety and complexity of the data are increased.
As shown in fig. 2, an embodiment of the present application further provides another implementation manner for generating the first data, which includes the following specific steps:
step 201: and carrying out length conversion on the initial encrypted data to obtain comprehensive data.
In the embodiment of the present application, the method for the server to perform length transformation on the initial encrypted data to obtain the comprehensive data may be various, and the embodiment of the present application provides several feasible implementation methods.
In one implementation, a data length value of the initial encrypted data may be determined; and adding second data after the initial encryption data to obtain comprehensive data, wherein the second data is the data length value of the initial encryption data.
Specifically, after the server obtains the initial encrypted data, a data length value N of the initial encrypted data is determined, where N is a positive integer. And adding second data after the server encrypts the data initially to obtain comprehensive data, wherein the second data is the data length value of the initial encrypted data.
For example, if the initial encrypted data is bcda, the server determines that the data length value of bcda is 4, and then the server adds 4 to bcda, resulting in the synthesized data bcda 4.
The second data represents a data length value of the initial encrypted data, and the server locates the second data behind the initial encrypted data so that the data length value of the initial encrypted data can be known through the second data when the final encrypted data is decrypted.
In another implementation, a data length value of the initial encrypted data may be determined; and adding third data after the initial encrypted data to obtain comprehensive data, wherein the third data is specific data corresponding to the data length value of the initial encrypted data.
Specifically, after determining the data length value of the initial encrypted data, the server determines specific data corresponding to the data length value of the initial encrypted data according to the corresponding relationship between the data length value and the data, takes the specific data as third data, and adds the third data after the initial encrypted data to obtain comprehensive data.
For example, the initial encrypted data is bcda, the server determines that the data length value of bcda is 4, and the specific data corresponding to 4 is "+", then the server sets "+" to bcda, resulting in the integrated data bcda +.
Step 202: and determining the comprehensive data length of the comprehensive data, and judging whether the evolution result of the comprehensive data length is an integer.
In the embodiment of the application, after the server obtains the comprehensive data, the comprehensive data length of the comprehensive data is determined, and whether the evolution result of the comprehensive data length is an integer is judged. If the server determines that the root result of the length of the integrated data is not an integer, executing step 203; if the server determines that the root result of the integrated data length is an integer, step 204 is performed.
Step 203: additional integrated data is generated based on the integrated data, and the additional integrated data is taken as the first data.
Wherein the root result of the data length of the additional integrated data is an integer.
In the embodiment of the application, if the server determines that the root result of the length of the integrated data is not an integer, the server generates additional integrated data based on the integrated data, and takes the additional integrated data as the first data, wherein the root result of the length of the additional integrated data is an integer.
For example, if the integrated data is bcda4, the integrated data length is 5, and the root result is not an integer, then the server generates additional integrated data bcda12354, having bcda12354 as the first data.
Step 204: and taking the integrated data as first data.
In the embodiment of the application, if the server determines that the root result of the length of the comprehensive data is an integer, the server takes the comprehensive data as the first data.
For example, if the synthetic data is bcda12358, the synthetic data length is 9, and the root result is an integer 3, then the server has bcda12358 as the first data.
Optionally, as shown in fig. 3, generating additional integrated data based on the integrated data includes:
step 301: and determining the minimum value which is larger than the comprehensive data length and the evolution result is an integer.
In the embodiment of the application, if the root result of the comprehensive data length is not an integer, the server determines a minimum numerical value which is larger than the comprehensive data length and the root result is an integer, so that the minimum integer root result is an integer.
For example, if the combined data length is 5, the square result of 5 is not an integer, then the server determines that the minimum value of greater than 5 and the square result is an integer is 9.
Step 302: and calculating the difference value between the minimum value and the comprehensive data length.
In the embodiment of the application, the server calculates the difference between the minimum value and the comprehensive data length.
For example, the combined data length is 5, the minimum value is 9, and the server calculates the difference between 9 and 5 to be 4.
Step 303: and acquiring random data with the data length being the difference.
In the embodiment of the application, after the server calculates the difference between the minimum value and the comprehensive data length, the server obtains the random data with the data length being the difference from the preset database.
For example, the server calculates a difference between 9 and 5 to be 4, and then the server acquires random data having a data length of 4. The random data may be 1234, or |! The @ #, the embodiment of the present application does not specifically limit the random data.
Step 304: random data is inserted between the initial encrypted data and the second data, generating additional integrated data.
In the embodiment of the application, after the server acquires the random data, the random data is inserted between the initial encrypted data and the second data to obtain the additional comprehensive data, and due to the addition of the random data, the result of the evolution of the data length of the additional comprehensive data is an integer, so that the additional comprehensive data can be subjected to nonlinear two-dimensional conversion. The random data is inserted between the initial encrypted data and the second data, so that when the final encrypted data is decrypted, the data length value of the initial encrypted data can be known according to the second data, namely the last character of the final encrypted data.
Optionally, the process of decrypting the final encrypted data is as follows:
carrying out nonlinear two-dimensional conversion on the final encrypted data; performing nonlinear one-dimensional conversion on the final encrypted data after the nonlinear two-dimensional conversion to obtain first data; generating initial encrypted data according to the first data and a preset data transformation inverse rule; and decrypting the initial encrypted data to obtain the data to be encrypted.
The server performs nonlinear two-dimensional conversion on the final encrypted data; and carrying out nonlinear one-dimensional conversion on the final encrypted data after the nonlinear two-dimensional conversion to obtain first data. If the evolution result of the length of the comprehensive data is an integer in the encryption process of the data to be encrypted, the server takes the comprehensive data as first data; if the evolution result of the length of the comprehensive data is not an integer in the encryption process of the data to be encrypted, the server takes the additional comprehensive data as first data, generates initial encrypted data according to the first data and a preset data transformation inverse rule, and decrypts the initial encrypted data to obtain the data to be encrypted.
For example, the server performs nonlinear two-dimensional conversion on the final encrypted data; and performing nonlinear one-dimensional conversion on the final encrypted data after the nonlinear two-dimensional conversion to obtain first data bcda 12358. If the evolution result of the length of the comprehensive data is an integer in the encryption process of the data to be encrypted, the server determines that the comprehensive data is the same as the first data, the comprehensive data is bcda12358, the server removes the last character in the first data, the rest characters are used as initial encryption data bcda1235, and the initial encryption data is decrypted to obtain the data to be encrypted abcd 2346.
The server performs nonlinear two-dimensional conversion on the final encrypted data; and performing nonlinear one-dimensional conversion on the final encrypted data after the nonlinear two-dimensional conversion to obtain first data bcda 12354. If the evolution result of the comprehensive data length is not an integer in the encryption process of the data to be encrypted, the server can know that the data length of the initial encrypted data is 4 according to the second data 4, then the server keeps the first four data in the first data as the initial encrypted data bcda, and decrypts the initial encrypted data to obtain the data to be encrypted abcd.
The embodiment of the present application, as shown in fig. 4, further provides a flowchart of a data encryption method, which includes the following specific steps:
step 401: and encrypting the data to be encrypted by the secret key to obtain initial encrypted data.
In the embodiment of the application, the server initially encrypts the data to be encrypted through the secret key to obtain initial encrypted data.
Step 402: and carrying out length conversion on the initial encrypted data to obtain comprehensive data.
In the embodiment of the application, after the server obtains the initial encrypted data, a data length value N of the initial encrypted data is determined, wherein N is a positive integer. And adding second data after the server encrypts the data initially to obtain comprehensive data, wherein the second data is the data length value of the initial encrypted data.
Step 403: and determining the comprehensive data length of the comprehensive data, and judging whether the evolution result of the comprehensive data length is an integer.
If the root result of the integrated data length is an integer, go to step 404; if the root result of the integrated data length is not an integer, go to step 405.
Step 404: and carrying out nonlinear two-dimensional conversion on the comprehensive data, and then carrying out nonlinear one-dimensional conversion to obtain final encrypted data.
In the embodiment of the application, the server arranges the comprehensive data into a square matrix, and then serializes the square matrix through a Hilbert curve to obtain final encrypted data.
Step 405: and determining the minimum value which is larger than the comprehensive data length and the evolution result is an integer.
In the embodiment of the application, if the root result of the comprehensive data length is not an integer, the server determines a minimum numerical value which is larger than the comprehensive data length and the root result is an integer, so that the minimum integer root result is an integer.
Step 406: and calculating the difference value between the minimum value and the comprehensive data length.
In the embodiment of the application, the server calculates the difference between the minimum value and the comprehensive data length.
Step 407: and acquiring random data with the data length being the difference.
In the embodiment of the application, after the server calculates the difference between the minimum value and the comprehensive data length, the server obtains the random data with the data length being the difference from the preset database.
Step 408: random data is inserted between the initial encrypted data and the second data, and additional integrated data is generated based on the integrated data.
In the embodiment of the application, after the server acquires the random data, the random data is inserted between the initial encrypted data and the second data to obtain the additional comprehensive data.
Step 409: and carrying out nonlinear two-dimensional conversion on the additional comprehensive data, and then carrying out nonlinear one-dimensional conversion to obtain final encrypted data.
In the embodiment of the application, the server arranges the additional comprehensive data into a square matrix, and then serializes the square matrix through a Hilbert curve to obtain final encrypted data.
Corresponding to the above method embodiment, an embodiment of the present application further provides a data encryption apparatus, and as shown in fig. 5, the apparatus includes:
the encryption module 501 is configured to encrypt data to be encrypted by using a secret key to obtain initial encrypted data;
a first generating module 502, configured to generate first data according to a preset data transformation rule and initial encrypted data, where an evolution result of a data length of the first data is an integer;
a first conversion module 503, configured to perform nonlinear two-dimensional conversion on the first data;
the second conversion module 504 is configured to perform nonlinear one-dimensional conversion on the first data after the nonlinear two-dimensional conversion, so as to obtain final encrypted data.
Optionally, the generating module includes:
the transformation unit is used for carrying out length transformation on the initial encrypted data to obtain comprehensive data;
the judging unit is used for determining the comprehensive data length of the comprehensive data and judging whether the evolution result of the comprehensive data length is an integer;
a first generating unit configured to generate additional integrated data based on the integrated data if an evolution result of the integrated data length is not an integer, and to take the additional integrated data as first data, wherein the evolution result of the data length of the additional integrated data is an integer;
and a second generation unit configured to take the integrated data as the first data if the evolution result of the integrated data length is an integer.
Optionally, the transformation unit includes:
the first determining subunit is used for determining a data length value of the initial encrypted data;
and the adding subunit is used for adding second data after the initial encrypted data to obtain the comprehensive data, wherein the second data is the data length value of the initial encrypted data.
Optionally, the first generating unit includes:
the second determining subunit is used for determining the minimum numerical value which is larger than the length of the comprehensive data and the evolution result of which is an integer;
the calculating subunit is used for calculating the difference value between the minimum value and the comprehensive data length;
the acquisition subunit is used for acquiring random data with data length as a difference value;
and the generating subunit is used for inserting the random data between the initial encrypted data and the second data to generate additional comprehensive data.
Optionally, the first conversion module 503 includes:
and a first conversion unit for arranging the first data into a square matrix.
Optionally, the second conversion module 504 includes:
and the second conversion unit is used for serializing the square matrix through a Hilbert curve to obtain final encrypted data.
Optionally, the method further comprises:
the third conversion module is used for carrying out nonlinear two-dimensional conversion on the final encrypted data;
the fourth conversion module is used for carrying out nonlinear one-dimensional conversion on the final encrypted data after the nonlinear two-dimensional conversion to obtain first data;
the second generation module is used for generating initial encrypted data by the first conversion module according to the first data and a preset data conversion inverse rule;
and the decryption module is used for decrypting the initial encrypted data to obtain the data to be encrypted.
The embodiment of the application provides a data encryption method, the data to be encrypted is encrypted, nonlinear transformation between one dimension and two dimensions is carried out, the data sequence is disordered, the complexity of data encryption is improved, meanwhile, random data with variable data length are added into the data, the complexity of data encryption is improved, the encrypted data are prevented from being cracked, and the safety of the data is improved.
Based on the same technical concept, an embodiment of the present invention further provides an electronic device, as shown in fig. 6, including a processor 601, a communication interface 602, a memory 603, and a communication bus 604, where the processor 601, the communication interface 602, and the memory 603 complete mutual communication through the communication bus 604,
a memory 603 for storing a computer program;
the processor 601 is configured to implement the above steps when executing the program stored in the memory 603.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
In a further embodiment provided by the present invention, there is also provided a computer readable storage medium having stored therein a computer program which, when executed by a processor, implements the steps of any of the methods described above.
In a further embodiment provided by the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform any of the methods of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (14)

1. A method for data encryption, the method comprising:
encrypting data to be encrypted by using a secret key to obtain initial encrypted data;
generating first data according to a preset data transformation rule and the initial encrypted data, wherein the evolution result of the data length of the first data is an integer;
performing nonlinear two-dimensional conversion on the first data;
and carrying out nonlinear one-dimensional conversion on the first data after the nonlinear two-dimensional conversion to obtain final encrypted data.
2. The method according to claim 1, wherein the generating first data according to a preset data transformation rule and the initial encrypted data comprises:
carrying out length transformation on the initial encrypted data to obtain comprehensive data;
determining the comprehensive data length of the comprehensive data, and judging whether the evolution result of the comprehensive data length is an integer;
if the evolution result of the length of the integrated data is not an integer, generating additional integrated data based on the integrated data, and taking the additional integrated data as the first data, wherein the evolution result of the length of the additional integrated data is an integer;
and if the evolution result of the length of the comprehensive data is an integer, taking the comprehensive data as the first data.
3. The method of claim 2, wherein the transforming the initial encrypted data into the integrated data comprises:
determining a data length value of the initial encrypted data;
and adding second data after the initial encrypted data to obtain comprehensive data, wherein the second data is the data length value of the initial encrypted data.
4. The method of claim 3, wherein the generating additional synthetic data based on the synthetic data comprises:
determining a minimum numerical value which is larger than the length of the comprehensive data and the evolution result of which is an integer;
calculating the difference between the minimum value and the length of the comprehensive data;
acquiring random data with the data length being the difference value;
inserting the random data between the initial encrypted data and the second data to generate additional integrated data.
5. The method of claim 1, wherein the non-linear two-dimensional transforming the first data comprises:
arranging the first data into a square matrix.
6. The method according to claim 5, wherein the performing nonlinear one-dimensional conversion on the nonlinear two-dimensional converted first data to obtain final encrypted data comprises:
and serializing the square matrix through a Hilbert curve to obtain final encrypted data.
7. The method of claim 1, further comprising:
performing nonlinear two-dimensional conversion on the final encrypted data;
performing nonlinear one-dimensional conversion on the final encrypted data after the nonlinear two-dimensional conversion to obtain the first data;
generating the initial encrypted data according to the first data and a preset data transformation inverse rule;
and decrypting the initial encrypted data to obtain the data to be encrypted.
8. An apparatus for encrypting data, the apparatus comprising:
the encryption module is used for encrypting the data to be encrypted through the secret key to obtain initial encrypted data;
the first generation module is used for generating first data according to a preset data transformation rule and the initial encrypted data, wherein the evolution result of the data length of the first data is an integer;
the first conversion module is used for carrying out nonlinear two-dimensional conversion on the first data;
and the second conversion module is used for carrying out nonlinear one-dimensional conversion on the first data after the nonlinear two-dimensional conversion to obtain final encrypted data.
9. The apparatus of claim 8, wherein the first generating module comprises:
the transformation unit is used for carrying out length transformation on the initial encrypted data to obtain comprehensive data;
the judging unit is used for determining the comprehensive data length of the comprehensive data and judging whether the evolution result of the comprehensive data length is an integer;
a first generating unit, configured to generate additional integrated data based on the integrated data if an evolution result of the data length of the integrated data is not an integer, and use the additional integrated data as the first data, where the evolution result of the data length of the additional integrated data is an integer;
and a second generating unit, configured to use the integrated data as the first data if an evolution result of the length of the integrated data is an integer.
10. The apparatus of claim 9, wherein the transform unit comprises:
a first determining subunit, configured to determine a data length value of the initial encrypted data;
and the adding subunit is used for adding second data after the initial encrypted data to obtain comprehensive data, wherein the second data is a data length value of the initial encrypted data.
11. The apparatus of claim 10, wherein the first generating unit comprises:
the second determining subunit is used for determining a minimum numerical value which is larger than the length of the comprehensive data and the evolution result of which is an integer;
the calculating subunit is used for calculating the difference value between the minimum value and the comprehensive data length;
the acquiring subunit is used for acquiring random data with the data length being the difference value;
and the inserting subunit is used for inserting the random data between the initial encrypted data and the second data to generate additional comprehensive data.
12. The apparatus of claim 8, wherein the first conversion module comprises:
and the arrangement unit is used for arranging the first data into a square matrix.
13. The apparatus of claim 12, wherein the second conversion module comprises:
and the serialization unit is used for serializing the square matrix through a Hilbert curve to obtain final encrypted data.
14. The apparatus of claim 8, further comprising:
the third conversion module is used for carrying out nonlinear two-dimensional conversion on the final encrypted data;
the fourth conversion module is used for carrying out nonlinear one-dimensional conversion on the final encrypted data after the nonlinear two-dimensional conversion to obtain the first data;
the second generation module is used for generating the initial encrypted data according to the first data and a preset data transformation inverse rule;
and the decryption module is used for decrypting the initial encrypted data to obtain the data to be encrypted.
CN202010251449.0A 2020-04-01 2020-04-01 Data encryption method and device Active CN111611595B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010251449.0A CN111611595B (en) 2020-04-01 2020-04-01 Data encryption method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010251449.0A CN111611595B (en) 2020-04-01 2020-04-01 Data encryption method and device

Publications (2)

Publication Number Publication Date
CN111611595A true CN111611595A (en) 2020-09-01
CN111611595B CN111611595B (en) 2023-06-30

Family

ID=72205424

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010251449.0A Active CN111611595B (en) 2020-04-01 2020-04-01 Data encryption method and device

Country Status (1)

Country Link
CN (1) CN111611595B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1096390A2 (en) * 1999-11-01 2001-05-02 Matsushita Electric Industrial Co., Ltd. Two-dimensional orthogonal transformation method
CN103916248A (en) * 2014-04-10 2014-07-09 东南大学 Fully homomorphic encryption public key space compression method
CN104573782A (en) * 2014-12-05 2015-04-29 中国科学院信息工程研究所 One-dimensional code encoding and decoding method
CN105426765A (en) * 2015-07-09 2016-03-23 深圳百云信息技术有限公司 Two-dimensional code dynamic encryption and decryption algorithm

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1096390A2 (en) * 1999-11-01 2001-05-02 Matsushita Electric Industrial Co., Ltd. Two-dimensional orthogonal transformation method
CN103916248A (en) * 2014-04-10 2014-07-09 东南大学 Fully homomorphic encryption public key space compression method
CN104573782A (en) * 2014-12-05 2015-04-29 中国科学院信息工程研究所 One-dimensional code encoding and decoding method
CN105426765A (en) * 2015-07-09 2016-03-23 深圳百云信息技术有限公司 Two-dimensional code dynamic encryption and decryption algorithm

Also Published As

Publication number Publication date
CN111611595B (en) 2023-06-30

Similar Documents

Publication Publication Date Title
JP5911654B2 (en) Random number generator and stream cipher
EP3134994B1 (en) Method of obfuscating data
CN110505054B (en) Data processing method, device and equipment based on dynamic white box
CN112347498B (en) Encryption method, encryption device, electronic equipment and readable storage medium
CN109547201B (en) Encryption method of root key, computer readable storage medium and terminal equipment
WO2024077948A1 (en) Private query method, apparatus and system, and storage medium
US20160013933A1 (en) Order-preserving encryption system, device, method, and program
CN104038336A (en) Data encryption method based on 3DES
US20160226660A1 (en) Information processing apparatus, program, and storage medium
CN115603907A (en) Method, device, equipment and storage medium for encrypting storage data
CN111447059A (en) Ciphertext equivalence testing method, device, electronic equipment, storage medium and system
CN114268447B (en) File transmission method and device, electronic equipment and computer readable medium
CN111859435B (en) Data security processing method and device
CN111314270B (en) Data encryption and decryption method based on validity period uniform distribution symmetric algorithm
CN111611595A (en) Data encryption method and device
CN115941304A (en) Data encryption method and device, terminal equipment and computer readable storage medium
JP5436373B2 (en) Confidentiality enhancement processing arithmetic device and quantum cryptography communication terminal equipped with the same
CN115277064A (en) Data encryption method, data decryption method, data encryption device, data decryption device, electronic equipment and medium
JP7383985B2 (en) Information processing device, information processing method and program
CN113938270A (en) Data encryption method and device capable of flexibly reducing complexity
CN111314052B (en) Data encryption and decryption method
CN107241185A (en) Data transmitting and receiving method and transmission and reception device
Liu et al. A parallel encryption algorithm for dual-core processor based on chaotic map
CN107959670B (en) Dynamic password generation method and device, terminal equipment and storage medium
CN116049841B (en) Encryption method, device, equipment and medium for identity card number

Legal Events

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