CN115001661A - Data encryption method and device, computer equipment and storage medium - Google Patents

Data encryption method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN115001661A
CN115001661A CN202210623514.7A CN202210623514A CN115001661A CN 115001661 A CN115001661 A CN 115001661A CN 202210623514 A CN202210623514 A CN 202210623514A CN 115001661 A CN115001661 A CN 115001661A
Authority
CN
China
Prior art keywords
constant array
data
objective function
current
elements
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.)
Pending
Application number
CN202210623514.7A
Other languages
Chinese (zh)
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.)
Bank of China Ltd
Original Assignee
Bank of China 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 Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN202210623514.7A priority Critical patent/CN115001661A/en
Publication of CN115001661A publication Critical patent/CN115001661A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0643Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Power Engineering (AREA)
  • Storage Device Security (AREA)

Abstract

The application discloses a data encryption method, a data encryption device, computer equipment and a storage medium, which can be applied to the field of data processing or the field of finance so as to enhance the complexity of MD5 algorithm encryption. The method comprises the following steps: obtaining a second constant array according to the current first constant array and the control coefficient; respectively calculating objective function values of elements of the current first constant array and elements of the current second constant array; updating elements in the current first constant array according to the objective function value; the steps are circulated, and after the first constant array is updated for the preset times, the first constant array after the preset times is circulated is obtained; and encrypting the data to be encrypted by utilizing the first constant array after the circulation for the preset times. And updating the constant array by using the uncertainty of the function value difference, and endowing the uncertainty of the content of the elements in the constant array participating in the encryption operation.

Description

Data encryption method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of data processing, and in particular, to a data encryption method, apparatus, computer device, and storage medium.
Background
With the development of internet technology, various data encryption algorithms are frequently used, and the MD5 algorithm is widely applied to the field of general data encryption protection, for example, for password management, due to its characteristics of universality, stability and rapidness.
However, the encryption method of the current MD5 algorithm employs a calculation factor and an encryption algorithm, wherein the calculation factor includes a constant array, a displacement amount, an initial magic number, and the like. Since the constant array in the calculation factor is disclosed, the MD5 algorithm is easy to break, and the security is poor.
Disclosure of Invention
Based on the above problems, the present application provides a data encryption method, apparatus, device and computer storage medium, so as to enhance the complexity of MD5 algorithm encryption and improve security.
The embodiment of the application discloses the following technical scheme:
a first aspect of an embodiment of the present application provides a data encryption method, including:
step 1, obtaining a first objective function value according to the elements of the current first constant array and an objective function;
step 2, obtaining elements of a second constant array according to the elements and the control coefficients of the current first constant array;
step 3, obtaining a second objective function value according to the elements of the second constant array and the objective function;
step 4, updating the elements in the current first constant array according to the first objective function value and the second objective function value;
step 5, the step 1 to the step 4 are circulated until the circulation times reach the preset times, and a first constant array after the circulation times reach the preset times is obtained;
and 7, encrypting the data to be encrypted by utilizing the first constant array, the initial magic number, the displacement and the encryption function after the circulation for the preset times.
In one possible implementation manner, the step 4 includes:
calculating the difference between the second objective function value and the first objective function value to obtain a function value;
if the difference of the function values is smaller than zero, updating the current element of the first constant array according to the element of the second constant array; and if the difference of the function values is larger than zero, keeping the elements of the current first constant array unchanged.
In one possible implementation manner, the step 2 includes:
and multiplying each element in the current first constant array by the control coefficient to obtain an element of the second constant array.
In one possible implementation, the method further includes: and periodically replacing the target function, the control coefficient and the preset times.
In one possible implementation, the step 6 includes:
carrying out data filling on the data to be encrypted, so that the length of the filled data is integral multiple of a preset value;
dividing the filled data into multiple data blocks, wherein the length of each data block is equal to the preset value;
dividing each block of data into a plurality of groups of data;
and sequentially performing sub-cycle processing on each group of data by using the second constant array, the initial magic number, the displacement and the encryption function to obtain encrypted data.
A second aspect of the embodiments of the present application provides a data encryption apparatus, including:
the first calculation unit is used for obtaining a first objective function value according to the elements of the current first constant array and the objective function;
the second constant array obtaining unit is used for obtaining a second constant array according to the current first constant array and the control coefficient;
the second calculation unit is used for obtaining a second objective function value according to the elements of the second constant array and the objective function;
the updating unit is used for updating elements in the current first constant array according to the first objective function value and the second objective function value;
the current first constant number obtaining unit is used for circularly executing the operations of the first calculating unit, the second constant number obtaining unit, the second calculating unit and the updating unit until the circulation times reach the preset times, and obtaining the first constant number after the circulation times reach the preset times;
and the encryption unit is used for encrypting the data to be encrypted by utilizing the first constant array, the initial magic number, the displacement and the encryption function after the circulation for the preset times.
In one possible implementation manner, the updating unit includes:
a difference of function values calculating unit, configured to calculate a difference of function values obtained by subtracting the first objective function value from the second objective function value;
the updating subunit is configured to update, according to the element of the second constant array, an element of the current first constant array if the difference between the function values is smaller than zero; and if the difference of the function values is larger than zero, keeping the elements of the current first constant array unchanged.
In a possible implementation manner, the second constant array obtaining unit is specifically configured to:
and multiplying each element in the first constant array by the control coefficient to obtain an element of the second constant array.
A third aspect of embodiments of the present application provides a computer device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the data encryption method according to any one of the first aspect of the embodiments of the present application when executing the computer program.
A fourth aspect of the embodiments of the present application provides a computer-readable storage medium, where instructions are stored, and when the instructions are executed on a terminal device, the instructions cause the terminal device to execute a data encryption method according to any one of the first aspect of the embodiments of the present application.
Compared with the prior art, the method has the following beneficial effects:
the data encryption method comprises the steps of 1, obtaining a first objective function value according to elements of a current first constant array and an objective function; step 2, obtaining a second constant array according to the current first constant array and the control coefficient; step 3, obtaining a second objective function value according to the elements of the second constant array and the objective function; step 4, updating the elements in the current first constant array according to the first objective function value and the second objective function value; step 5, the step 1 to the step 4 are circulated until the circulation times are equal to the preset times, and a first constant array after the circulation times are preset is obtained; and 6, encrypting the data to be encrypted by utilizing the first constant array, the initial magic number, the displacement and the encryption function after the circulation for the preset times. The constant array is updated by using the uncertainty of the function value difference, the uncertainty of the content of the elements in the constant array participating in the encryption operation is given, the encryption complexity of the MD5 algorithm is enhanced, and the security is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, 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 terminal device according to an embodiment of the present disclosure;
fig. 2 is a flowchart of a data encryption method according to an embodiment of the present application;
fig. 3 is a flowchart illustrating an application data encryption method for encrypting data to be encrypted according to an embodiment of the present application;
fig. 4 is a schematic diagram of a data format after data padding is performed on original data according to an embodiment of the present application;
fig. 5 is a structural diagram of a data encryption device according to an embodiment of the present application;
fig. 6 is a block diagram of a computer device according to an embodiment of the present disclosure.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, embodiments accompanying the drawings are described in detail below.
As described above, the current MD5 algorithm is fixed in calculation mode, and the specific sequence and content of the calculation factors are disclosed. Therefore, the MD5 algorithm has a high probability of being broken.
In order to facilitate understanding of the data encryption method provided in the embodiments of the present application, the following description will be made with reference to a scenario example shown in fig. 1. Fig. 1 is a schematic diagram of a scene example provided in an embodiment of the present application. The method can be applied to the terminal device 101.
In practical application, the terminal device 101 executes step 1, and calculates a first objective function value according to the current elements of the first constant array and the objective function; step 2, obtaining a second constant array according to the current first constant array and the random disturbance function; step 3, calculating a second objective function value according to the elements of the second constant array and the objective function; step 4, updating elements in the current first constant array according to the first objective function value, the second objective function value and the current control parameter; step 5, the step 1 to the step 4 are circulated until the circulation times are equal to the preset times, and a first constant array after the circulation times are preset is obtained; and 6, encrypting the data to be encrypted by utilizing the first constant array, the initial magic number, the displacement and the encryption function after the circulation for the preset times. The constant array is updated by using the uncertainty of the function value difference, the uncertainty of the content of the elements in the constant array participating in the encryption operation is given, the encryption complexity of the MD5 algorithm is enhanced, and the security is improved.
Those skilled in the art will appreciate that the block diagram shown in fig. 1 is only one example in which embodiments of the present application may be implemented. The scope of applicability of the embodiments of the present application is not limited in any way by this framework.
Based on the above description, the data encryption method provided by the embodiment of the present application will be described in detail below with reference to the drawings.
Referring to fig. 2, the figure is a flowchart of a data encryption method provided in an embodiment of the present application. As shown in fig. 2, the method includes:
step 1, obtaining a first objective function value according to the elements of the current first constant array and the objective function.
In one example, the objective function may be on demandAn objective function is defined, for example, as E (). The initial first constant array, i.e. the initial solution of the objective function, may be a Kj constant array, containing 64 elements, and is represented as: kj t ={Kj 0 ,Kj 1 ,Kj 2 ......Kj 63 Where t denotes an index value. Using these 64 elements as the initial solution of the objective function, the corresponding objective function value E (Kj) is calculated i ) Wherein kj i The element with index value i in the Kj constant array is used.
And 2, obtaining a second constant array according to the current first constant array and the control coefficient.
In some embodiments, the elements of the first constant array are multiplied by the control coefficients to obtain the elements of the second constant array.
In one example, the second constant array may be represented as:
Kj' t2 ={kKj 0 ,kKj 1 ,kKj 2 ......kKj 63 in which Kj 0 ,Kj 1 ,Kj 2 ......Kj 63 For the elements of the first constant array, k represents the control coefficient and t2 represents the second constant array index value.
And 3, obtaining a second objective function value according to the elements of the second constant array and the objective function.
In one example, the second objective function value may be expressed as E (kKj) i ) Wherein, kKj i An element in the second constant array representing an element having an index value i corresponding to the first constant array.
And 4, updating the elements in the current first constant array according to the first objective function value and the second objective function value.
In some embodiments, the elements in the first constant array are updated as follows:
and calculating the difference between the second objective function value and the first objective function value to obtain the function value. And if the difference of the function values is smaller than zero, updating the current element of the first constant array according to the element of the second constant array. Otherwise, the elements of the current first constant array remain unchanged.
In one example, the difference in the function values may be expressed as Δ E i =E(kKj i )-E(Kj i ). If Δ E 1 <0,ΔE 2 If > 0, then Kj in the Kj constant array is added 1 Updated to kKj 1 ,Kj 2 And is not changed.
Because the constraint condition for updating the first constant array only has the difference between the first function value and the second function value, the current first constant array after updating iteration is the same as the current first constant array obtained by the first constant array under the same target function, the same control coefficient and the same preset times of inner loop. The consistency of the encryption mode used by the data to be encrypted from the same data source is facilitated.
In some embodiments, when data to be encrypted of different data sources is encrypted, the data encryption method provided in the embodiments of the present application further periodically changes the control coefficient, the objective function, and the preset number of times.
And 5, circulating the steps 1 to 4 until the circulation times are equal to the preset times, and obtaining a first constant array after the circulation times are preset.
In one example, the initial element Kj in the array is constant with Kj 1 、Kj 2 For example, in the first cycle, Δ E 1 =E(kKj 1 )-E(Kj 1 ),ΔE 2 =E(kKj 2 )-E(Kj 2 ) If Δ E 1 <0,ΔE 2 If > 0, then Kj in the Kj constant array is added 1 Is updated to kKj 1 ,Kj 2 And is not changed. In the second cycle,. DELTA.E 1 =E(k 2 Kj 1 )-E(kKj 1 ),ΔE 2 =E(kKj 2 )-E(Kj 2 ) If Δ E 1 <0,ΔE 2 Is less than 0, and the two elements are respectively updated to be k 2 Kj 1 ,kKj 2
And 6, encrypting the data to be encrypted by utilizing the first constant array, the initial magic number, the displacement and the encryption function after the circulation for the preset times.
According to the data encryption method, the constant array is updated by using the positive and negative uncertainties of the function difference, the uncertainty is given to the content of elements in the constant array participating in encryption operation, the encryption complexity of the MD5 algorithm is enhanced, and the security is improved.
Referring to fig. 3, this figure is a flowchart of encrypting data to be encrypted by using a data encryption method according to an embodiment of the present application. As shown in fig. 3, the current Kj constant array element is used as the solution of the objective function E, so as to obtain a first objective function value E1. And obtaining elements of a second constant array according to the current Kj constant array and the control coefficient, obtaining a second objective function value E2, calculating delta E as E2-E1, updating the elements of the current Kj constant array if the delta E is less than 0, and otherwise, keeping the elements of the current Kj constant array unchanged. Element Kj of constant array with current Kj 1 ,Kj 2 As an example of an initial solution to the objective function, in the first cycle, the objective function values are E (Kj) respectively 1 ),E(Kj 2 ). Combining the control coefficient k to obtain the element kKj of the second constant array 1 ,kKj 2 Obtaining a second objective function value E as a new solution to the objective function (kKj) 1 ),E(kKj 2 ). Calculating the difference Δ E of the objective function values of the two solutions 1 =E(kKj 1 )-E(Kj 1 ),ΔE 2 =E(kKj 2 )-E(Kj 2 ) If Δ E 1 <0,ΔE 2 If > 0, then Kj in the Kj constant array is added 1 Is updated to kKj 1 ,Kj 2 And is not changed. In the second cycle,. DELTA.E 1 =E(k 2 Kj 1 )-E(kKj 1 ),ΔE 2 =E(kKj 2 )-E(Kj 2 ) If Δ E 1 <0,ΔE 2 < 0, the two elements are updated to k respectively 2 Kj 1 ,kKj 2 . And circulating the preset times of the steps to update the Kj constant array for the preset iterative times, and then obtaining the current Kj constant array which is circulated for the preset times and recording as the Kj constant array for distinguishing. And encrypting the data to be encrypted by using the current Kj' constant array, the initial magic number, the displacement and the encryption function after circulating the preset times.
In some embodiments, the method for encrypting the data to be encrypted is as follows:
and 701, performing data filling on the data to be encrypted to enable the length of the filled data to be integral multiple of a preset value.
In one example, the preset value may be 512. The data filling method is described below with the preset value of 512 as an example:
(1) a 1 and an infinite number of 0's are padded after the original data (i.e., the data to be encrypted) such that the result of the remainder of the bit length to 512 is equal to 448, and thus, the bit length of the data padded with a 1 and an infinite number of 0's will be extended to N × 512+448, N being a non-negative integer, N may be zero.
(2) The length (in bit) of original data represented by 64 bits is added after the data filled with a 1 and an infinite number of 0, and if the length of the original data represented by binary exceeds 64 bits, the lower 64 bits are taken.
After the two steps of processing, M is N × 512+448+64 is (N +1) × 512, that is, the length M of the padded data is exactly an integer multiple of 512. Fig. 4 is a schematic diagram of a data format of original data after being filled in according to an embodiment of the present application.
Step 702, dividing the filled data into integer-valued block data, where the length of each block data is equal to a preset value.
Implementation of MD5 requires a main loop process every 512 bytes, and therefore, the padded data of length (N +1) × 512 is divided into a plurality of block data, each of which is 512 bits (64 bytes), i.e., the preset value is 512. The total number of the main circulation is N + 1.
And 703, dividing each block data into a plurality of small groups of data.
Each block of data is divided into 16 small groups of data, each of which has a length of 32 bits (4 bytes). The 16 minor groups of data were named M0-M15.
And step 704, performing sub-loop processing on each group of data by using the second constant array, the initial magic number, the displacement and the encryption function in sequence to obtain encrypted data.
And (3) sub-cycle treatment: each small group of data is processed by one sub-cycle, and the 16 small groups of data are 1 cycle, and 4 cycles are performed in total, namely 64 sub-cycles. Each main loop process comprises 64 sub-loops. The N +1 main-cycle processing includes (N +1) × 64 sub-cycle processing.
The MD5 operation uses a 128-bit MD5 register to hold intermediate variables and the final result. The buffer can be seen as 4 32-bit registers (a, B, C, D) starting with the lower order byte preceding a and ending with the upper order byte preceding D.
The input of the next sub-loop process is the output of the previous sub-loop process, so before the loop process starts, a 128-bit MD buffer, also denoted as 4 32-bit registers (a, B, C, D), is initialized, i.e. 4 normal numbers are required to be stored as initial magic numbers in the registers (a, B, C, D), which may be:
a=0x67452301,b=0xefcdab89,c=0x98badcfe,d=0x10325476。
the encryption function is 4 nonlinear functions F, G, H, I. In a 4-round cycle, F, G, H, and I are used alternately to perform logical operations on data, F for the first round, G for the second round, H for the third round, and I for the fourth round. I.e. the encryption function is changed every 16 sub-cycles.
The 4 non-linear functions may be:
F(X,Y,Z)=(X&Y)|((~X)&Z);
G(X,Y,Z)=(X&Y)|(Y&(~Z));
H(X,Y,Z)=X^Y^Z;
I(X,Y,Z)=Y^(X|(~Z));
wherein, "&" is AND, "|" is OR, "-" is NOT, "^" is XOR. X, Y, Z are merely exemplary of 3 independent variables.
The 4-cycle core formula corresponds to 4 non-linear functions, and the 4 core formulas (also called round functions) can be:
FF (a, b, c, d, Mi, s, Kj "): represents a ═ b + ((a + F (b, c, d) + Mi + Kj ") < <;
GG (a, b, c, d, Mi, s, Kj "): represents a ═ b + ((a + G (b, c, d) + Mi + Kj ") < <;
HH (a, b, c, d, Mi, s, Kj "): represents a ═ b + ((a + H (b, c, d) + Mi + Kj ") < <;
II (a, b, c, d, Mi, s, Kj "): represents a ═ b + ((a + I (b, c, d) + Mi + Kj ") < <;
in the 4 core formulas, Kj "is a constant element whose index value in the current first constant array is equal to the current number of subcycles, Mi is the ith of the group data M0-M15, and a, B, C and D are the current values of MD buffers (a, B, C and D), respectively"<<<s "indicates a cycle left shift by s bits," + "indicates: die 2 32 And (4) adding.
The operational relationship expressed by the 4 core formulas is as follows: b, c and d are taken firstly to carry out nonlinear function (F or G or H or I) operation. And adding a, Mi and Kj' to the obtained result in sequence, circularly shifting the obtained result backwards by a specified left shift amount, adding b, and assigning the obtained result to a.
After each calculation, the MD buffer is circularly right shifted. After one-step operation, the MD buffer is (AA, BB, CC, DD), and the loop right shift is executed to make a ═ DD, B ═ AA, C ═ BB, and D ═ CC.
The data is output according to the last result (A, B, C, D) of the MD buffer, and 128 bits of data are output from A to D in the order from low byte to high byte as the last encryption result. The encrypted data length is 128 bits regardless of the original data length.
The constant elements used in the 64 sub-loops of the Kj "constant array (the current first constant array after the preset number of loops) are all different, and the index value of the Kj" constant array corresponds to the number of sub-loop processing.
The displacement amount can be a left shift amount S in a cycle, the S used in each cycle is different, each 4 cycles is a main cycle treatment, the total left shift amount is 4, and the 4 left shift amounts can be:
S[0]={7,12,17,22};S[1]={5,9,14,20};
S[2]={4,11,16,23};S[3]={6,10,15,21}。
referring to fig. 5, which provides a data encryption apparatus according to an embodiment of the present application, as shown in fig. 5, the apparatus includes:
a first obtaining unit 410, configured to obtain a first objective function value according to an element of a current first constant array and an objective function;
a second obtaining unit 420, configured to obtain a second constant array according to the current first constant array and the random disturbance function;
a third obtaining unit 430, configured to obtain a second objective function value according to an element of the second constant array and the objective function;
an updating unit 440, configured to update an element in the current first constant array according to the first objective function value and the second objective function value;
a fourth obtaining unit 450, configured to perform operations of the first obtaining unit 410, the second obtaining unit 420, the third obtaining unit 430, and the updating unit 440 in a loop until the loop is performed for a preset number of times, so as to obtain a first constant array after the loop is performed for the preset number of times;
and an encrypting unit 460, configured to encrypt the data to be encrypted by using the first constant array, the initial magic number, the displacement amount, and the encryption function after the preset number of cycles.
In some embodiments, the update unit 440 includes:
calculating a second objective function value minus the first objective function value to obtain a difference of function values;
if the difference of the function values is smaller than zero, updating the current element of the first constant array according to the element of the second constant array; if the difference of the function values is larger than zero, the elements of the current first constant array are kept unchanged.
In some embodiments, the second obtaining unit 420 includes:
and multiplying each element in the current first constant array by the control coefficient to obtain each element of the second constant array.
In some embodiments, the apparatus is further configured to periodically replace the control coefficients, the objective function, and the preset number of times.
In some embodiments, the encryption unit 460 includes:
carrying out data filling on data to be encrypted to enable the length of the filled data to be integral multiple of a preset value;
dividing the filled data into multiple-number-of-block data, wherein the length of each block data is equal to a preset value;
dividing each block of data into a plurality of groups of data;
and sequentially performing sub-cycle processing on each group of data by using the second constant array, the initial magic number, the displacement and the encryption function to obtain encrypted data.
According to the data encryption device, the uncertainty of the second constant array is generated by using the random disturbance function, the uncertainty of the content of elements in the constant array participating in encryption operation is given, the encryption complexity of the MD5 algorithm is enhanced, and the security is improved.
Embodiments of the present application provide a computer-readable storage medium on which a computer program is stored, where the computer program is executed by a processor to implement a data encryption method according to an embodiment of the present application.
In practice, the computer-readable storage medium may take any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present embodiment, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
As shown in fig. 6, an embodiment of the present application provides a schematic structural diagram of a computer device. Fig. 6 shows the computer device 12, and the computer device 12 is only an example and should not bring any limitation to the function and the scope of the application of the embodiment of the present invention.
As shown in FIG. 6, computer device 12 is in the form of a general purpose computing device. The components of computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 and the processing unit 16.
Bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Computer device 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by computer device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)30 and/or cache memory 32. Computer device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 6, and commonly referred to as a "hard drive"). Although not shown in FIG. 6, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
Computer device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), with one or more devices that enable a user to interact with computer device 12, and/or with any devices (e.g., network card, modem, etc.) that enable computer device 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 22. Also, computer device 12 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the Internet) via network adapter 20. As shown in FIG. 6, the network adapter 20 communicates with the other modules of the computer device 12 via the bus 18. It should be appreciated that although not shown in FIG. 6, other hardware and/or software modules may be used in conjunction with computer device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processor unit 16 executes various functional applications and data processing, such as implementing a data encryption method provided by an embodiment of the present application, by executing programs stored in the system memory 28.
The data encryption method, the data encryption device, the computer equipment and the storage medium can be used in the financial field or other fields, for example, can be used in an application scenario of APP payment verification in the financial field. The other fields are arbitrary fields other than the financial field, for example, the data processing field. The above description is only an example and does not limit the application field of the invention name provided by the present invention.
It is further noted that, herein, 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 above description is only one specific embodiment of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present application should be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method for data encryption, comprising:
step 1, obtaining a first objective function value according to the elements of the current first constant array and an objective function;
step 2, obtaining elements of a second constant array according to the elements and the control coefficients of the current first constant array;
step 3, obtaining a second objective function value according to the elements of the second constant array and the objective function;
step 4, updating elements in the current first constant array according to the first objective function value and the second objective function value;
step 5, the step 1 to the step 4 are circulated until the circulation times reach the preset times, and a first constant array after the circulation times reach the preset times is obtained;
and 6, encrypting the data to be encrypted by using the first constant array, the initial magic number, the displacement and the encryption function after the circulation for the preset times.
2. The method of claim 1, wherein the step 4 comprises:
calculating the difference between the second objective function value and the first objective function value to obtain a function value;
if the difference of the function values is smaller than zero, updating the elements of the current first constant array according to the elements of the second constant array; and if the difference of the function values is larger than zero, keeping the elements of the current first constant array unchanged.
3. The method of claim 1, wherein the step 2 comprises:
and multiplying each element in the current first constant array by the control coefficient to obtain an element of the second constant array.
4. The method of claim 1, further comprising: and periodically replacing the target function, the control coefficient and the preset times.
5. The method according to any one of claims 1-4, wherein said step 6 comprises:
carrying out data filling on the data to be encrypted, so that the length of the filled data is integral multiple of a preset value;
dividing the filled data into multiple data blocks, wherein the length of each data block is equal to the preset value;
dividing each block of data into a plurality of groups of data;
and sequentially performing sub-cycle processing on each group of data by using the second constant array, the initial magic number, the displacement and the encryption function to obtain encrypted data.
6. A data encryption apparatus, comprising:
the first obtaining unit is used for obtaining a first objective function value according to the current element of the first constant array and the objective function;
the second obtaining unit is used for obtaining a second constant array according to the current first constant array and the control coefficient;
a third obtaining unit, configured to obtain a second objective function value according to the element of the second constant array and the objective function;
the updating unit is used for updating elements in the current first constant array according to the first objective function value and the second objective function value;
the fourth obtaining unit is used for circularly executing the operations of the first obtaining unit, the second obtaining unit, the third obtaining unit and the updating unit until the circulation frequency reaches the preset frequency, and obtaining the current first constant array after the circulation frequency reaches the preset frequency;
and the encryption unit is used for encrypting the data to be encrypted by utilizing the first constant array, the initial magic number, the displacement and the encryption function after the circulation for the preset times.
7. The apparatus of claim 6, wherein the updating unit comprises:
a difference of function values calculating unit, configured to calculate a difference of function values obtained by subtracting the first objective function value from the second objective function value;
the updating subunit is configured to update, according to the element of the second constant array, an element of the current first constant array if the difference between the function values is smaller than zero; and if the difference of the function values is larger than zero, keeping the elements of the current first constant array unchanged.
8. The apparatus according to claim 6, wherein the second obtaining unit is specifically configured to:
and multiplying each element in the current first constant array by the control coefficient to obtain an element of the second constant array.
9. A computer device, comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the data encryption method of any one of claims 1-6 when executing the computer program.
10. A computer-readable storage medium having stored therein instructions which, when run on a terminal device, cause the terminal device to perform a data encryption method according to any one of claims 1-6.
CN202210623514.7A 2022-06-02 2022-06-02 Data encryption method and device, computer equipment and storage medium Pending CN115001661A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210623514.7A CN115001661A (en) 2022-06-02 2022-06-02 Data encryption method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210623514.7A CN115001661A (en) 2022-06-02 2022-06-02 Data encryption method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115001661A true CN115001661A (en) 2022-09-02

Family

ID=83030475

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210623514.7A Pending CN115001661A (en) 2022-06-02 2022-06-02 Data encryption method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115001661A (en)

Similar Documents

Publication Publication Date Title
US10778410B2 (en) Homomorphic data encryption method and apparatus for implementing privacy protection
CN109791517B (en) Protecting parallel multiplication operations from external monitoring attacks
TWI642294B (en) Computer program product , system and method of cipher message with authentication instruction
US20230066955A1 (en) Efficient post-quantum secure software updates tailored to resource-constrained devices
US10235138B2 (en) Instruction to provide true random numbers
US11750403B2 (en) Robust state synchronization for stateful hash-based signatures
CN111444547B (en) Method, apparatus and computer storage medium for data integrity attestation
CN109844750B (en) Filling operation state determination
CN111339547B (en) Method for generating data tag, electronic device and computer storage medium
CN112149834B (en) Model training method, device, equipment and medium
CN115001661A (en) Data encryption method and device, computer equipment and storage medium
CN115016823B (en) Target software upgrading method, device, electronic equipment, medium and program product
JP2011259389A (en) Message authentication code generation device, message authentication code verification device, message authentication code generation method, message authentication code verification method, and program
CN111444535B (en) Method, apparatus and computer storage medium for generating aggregated data tag
CN111447072B (en) Method, apparatus and storage medium for generating data equivalent zero knowledge proof
CN115001660A (en) Data encryption method and device, computer equipment and storage medium
CN114969791A (en) Data encryption method and device, computer equipment and storage medium
CN115001663A (en) Data encryption method and device, computer equipment and storage medium
US9842086B2 (en) Calculation device, calculation method, and program
CN115001662A (en) Data encryption method and device, computer equipment and storage medium
CN111949738A (en) Block chain-based data storage deduplication method, terminal device and storage medium
CN108228081B (en) Method and apparatus for data protection
CN111339546B (en) Method for generating data tag, electronic device and computer storage medium
CN111444548B (en) Method, apparatus and computer storage medium for data integrity attestation
CN117353923B (en) Exercise method of lightweight hash encryption algorithm and related equipment

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