Data encryption method, device, equipment, storage medium and product
By performing multi-level encryption on the data source identifier and the original data, a hash value matrix is generated, which solves the problem of insufficient security of the MD5 algorithm in collision attacks and improves the encryption strength and security of the data.
Patent Information
- Application Number
- CN202410989229.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2044-07-22
AI Technical Summary
The existing MD5 algorithm is not secure enough against collision attacks, and is easily predicted and cracked, causing file consistency verification to fail.
By acquiring the original data and data source identifier, the target element is extracted from the original data according to the preset encryption level, and the data source identifier, target element and original data are encrypted respectively to generate the first, second and third hash values. These hash values are placed in different positions of the preset empty matrix to form a hash value matrix, which increases the complexity of the encryption process.
It improves data security, reduces the risk of collision attacks inherent in message digest algorithms, and enhances the encryption strength of data.
Smart Images

Figure CN119030704B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of information security, and in particular to a data encryption method and device, equipment, storage medium and product. BACKGROUND
[0002] Message-Digest Algorithm 5 (MD5) is a cryptographic hash function that can convert data into a 128-bit (16-byte) hash value. Such a hash value is used to ensure the integrity and consistency of information transmission. MD5 can generate a "digital fingerprint" of any file, and minor changes to the file will directly result in a huge change in the digital fingerprint. Therefore, it is widely used for consistency checking of various data types of files such as text, audio and video, to prevent file tampering. MD5 algorithm can also be used to generate fingerprint information of messages to verify the integrity and source of the messages.
[0003] However, the operation process of the current MD5 algorithm is fixed, which makes the encryption process easy to be predicted and cracked. For example, the MD5 algorithm has a fundamental problem of being unable to effectively deal with collision attacks. Collision attack refers to finding two different input values that produce the same hash value, thereby making the MD5 algorithm ineffective for file consistency checking. The security of the existing MD5 algorithm is insufficient. SUMMARY
[0004] The embodiments of the present application provide a data encryption method, device, equipment, storage medium and product, which can improve the security of data.
[0005] In a first aspect, the present application provides a data encryption method, comprising:
[0006] obtaining original data and a data source identifier of the original data;
[0007] extracting a target element corresponding to a number of levels from the original data according to a level number of a preset encryption level;
[0008] encrypting the data source identifier, the target element and the original data respectively, to obtain a first hash value, a second hash value and a third hash value;
[0009] placing the first hash value, the second hash value and the third hash value into a first preset position, a second preset position and a third preset position of a preset empty matrix respectively, to obtain a hash value matrix corresponding to the original data.
[0010] In some possible implementation manners, the extracting a target element corresponding to a number of levels from the original data according to a level number of a preset encryption level comprises:
[0011] obtaining a preset encryption interval value;
[0012] extracting target elements corresponding to the number of levels from the original data according to the preset encryption interval value.
[0013] In some possible implementation manners, the extracting target elements corresponding to the number of levels from the original data according to the preset encryption interval value includes:
[0014] extracting an initial element of the original data;
[0015] selecting data positions with intervals between the initial element and the data positions being integer multiples of the encryption interval value, the number of the data positions being equal to the number of levels;
[0016] extracting elements in the data positions;
[0017] in a case where there is no element in the data position, taking the number of intervals between the data position and the initial element as an element corresponding to the data position, and extracting the element.
[0018] In some possible implementation manners, after the obtaining the preset encryption interval value, the method further includes:
[0019] encrypting the preset encryption interval value to obtain a hash value corresponding to the preset encryption interval value;
[0020] adding the hash value corresponding to the preset encryption interval value to a fourth preset position of a preset empty matrix.
[0021] In some possible implementation manners, before the taking the preset empty matrix as the hash value matrix corresponding to the original data, the method further includes:
[0022] encrypting the value of the preset encryption level to obtain a hash value corresponding to the preset encryption level;
[0023] adding the hash value corresponding to the preset encryption level to a fifth preset position of a preset empty matrix.
[0024] In some possible implementation manners, before the taking the preset empty matrix as the hash value matrix corresponding to the original data, the method further includes:
[0025] obtaining preset encryption sequence information, the preset encryption sequence information indicating an arrangement sequence of information after encryption;
[0026] encrypting the preset encryption sequence information to obtain a hash value corresponding to the preset encryption sequence information;
[0027] The hash value corresponding to the preset encryption sequence information is added to a sixth preset position of a preset empty matrix.
[0028] In some possible implementation manners, the first hash value, the second hash value and the third hash value are respectively placed into a first preset position, a second preset position and a third preset position of a preset empty matrix to obtain the hash value matrix corresponding to the original data, and the method comprises the following steps of:
[0029] The first hash value is placed into a first row of the preset empty matrix.
[0030] The third hash value is placed into a last row of the preset empty matrix.
[0031] The third hash value is placed into a row of the preset empty matrix in which no hash value is placed to obtain the hash value matrix corresponding to the original data.
[0032] In a second aspect, the present application provides a data decryption method, comprising:
[0033] A first hash value corresponding to a data source identifier is extracted from a first preset position of the hash value matrix.
[0034] It is verified whether the first hash value matches a preset data source.
[0035] In the case of matching the preset data source, a second hash value corresponding to each of the elements is extracted from a second preset position of the hash value matrix, and a third hash value corresponding to the original data is extracted from a third preset position of the hash value matrix.
[0036] It is verified whether the second hash value and the third hash value match expected values.
[0037] In the case of matching the expected values, it is judged whether each of the elements corresponds to the original data.
[0038] In the case of each of the elements corresponding to the original data, data decryption is completed based on the original data.
[0039] In a third aspect, the present application provides a data encryption device, comprising:
[0040] An acquisition module is configured to acquire original data and a data source identifier of the original data.
[0041] An extraction module is configured to extract a target element corresponding to a number of levels from the original data according to a number of levels of a preset encryption level.
[0042] An encryption module is configured to respectively encrypt the data source identifier, the target element and the original data to obtain a first hash value, a second hash value and a third hash value.
[0043] inserting the first hash value, the second hash value and the third hash value into a first preset position, a second preset position and a third preset position of a preset empty matrix respectively to obtain a hash value matrix corresponding to the original data.
[0044] In a fourth aspect, the present application provides a data encryption device, which comprises a processor and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the data encryption method as described above.
[0045] In a fifth aspect, the present application provides a computer readable storage medium, which stores computer program instructions; the computer program instructions are executed by a processor to implement the data encryption method as described above.
[0046] In a sixth aspect, the present application provides a computer program product, instructions in the computer program product are executed by a processor of an electronic device to enable the electronic device to perform the data encryption method as described above.
[0047] The data encryption method, device, equipment, storage medium and product provided by the embodiments of the present application first acquire original data and a data source identifier of the original data, perform an encryption algorithm on the data source identifier, and obtain a first preset position of a preset empty matrix. Then, according to a preset encryption level, an encryption algorithm is performed on part of elements in the original data, corresponding hash values are calculated, a hash value matrix corresponding to the original data is calculated, and each hash value is added to a preset position of an empty matrix to obtain a hash value matrix corresponding to the original data. The complexity of the encryption process is increased, the risk of collision attack inherent in the message digest algorithm is reduced by using a matrix composed of multiple hash values, and the security of the data is improved. BRIEF DESCRIPTION OF DRAWINGS
[0048] The present application can be better understood from the following description of specific embodiments thereof, given by way of example and not of limitation, to be considered together with the accompanying drawings in which:
[0049] Other features, objects, and advantages of the present application will become more apparent from the following detailed description of non-limiting embodiments thereof, taken in conjunction with the accompanying drawings, in which like or similar elements refer to like or similar elements throughout.
[0050] Figure 1 is a flowchart of a data encryption method provided by an embodiment of the present application;
[0051] Figure 2 is a flowchart of a data decryption method provided by an embodiment of the present application;
[0052] Figure 3 is a schematic diagram of a constituent part of an encryption matrix provided by another embodiment of the present application;
[0053] Figure 4 is a structural schematic diagram of a data encryption device provided by an embodiment of the present application;
[0054] Figure 5 is a hardware structural schematic diagram of a data encryption device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0055] The features and exemplary embodiments of various aspects of the present application will be described in detail below with reference to the drawings. To make the purposes, technical solutions and advantages of the present application more clear, the present application will be further described in detail below with reference to the drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, but not to limit the present application. The present application can be implemented without some of the specific details by those skilled in the art. The following description of the embodiments is only to provide a better understanding of the present application by showing examples of the present application.
[0056] It should be noted that, in this document, relational terms such as first and second and the like can only be used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including", or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or apparatus that includes a list of elements does not only include those elements, but also includes other elements not explicitly listed or other elements inherent to such process, method, article or apparatus. Without more limitations, an element defined by the phrase "comprising a" does not exclude the presence of additional identical elements in the process, method, article or apparatus that includes the element.
[0057] To solve the problems in the prior art, the embodiments of the present application provide a data encryption method, device, equipment, storage medium and product. First, the data encryption method provided by the embodiments of the present application will be introduced.
[0058] Figure 1 A flowchart of a data encryption method provided by an embodiment of the present application is shown. This method can be executed by the data encryption device described above, as shown in Figure 1 The method includes the following steps S101 to S104.
[0059] Step S101: Obtain original data and a data source identifier of the original data.
[0060] In a specific implementation, the original data can be obtained through network requests, file reading, database queries, etc. These data can be of any type, such as text, numbers, images, videos, etc. According to the data source of the above-mentioned original data, the data source identifier of the original data is obtained, which usually refers to the source of the data or the unique identifier of the data.
[0061] As another example, the data source identifier can be a file path, a uniform resource locator (URL), a primary key of a database record, etc.
[0062] Step S102: According to the number of preset encryption levels, extract a corresponding number of target elements from the above-mentioned original data.
[0063] In a specific implementation, the encryption level is preset to control the number of target elements extracted. For example, if it is preset to 3, 3 target elements need to be extracted from the original data. Then extract a corresponding number of target elements from the above-mentioned original data.
[0064] As another example, the method of extracting target elements depends on the type of data. For text data, it can be extracting a specified number of words or sentences; for image data, it can be extracting a specified number of pixel regions or features; for video data, it can be extracting a specified number of frames. The process of these extractions needs to ensure the integrity and representativeness of the data.
[0065] Step S103: Encrypt the above-mentioned data source identifier, target element and original data respectively, and obtain the first hash value, second hash value and third hash value correspondingly.
[0066] In a specific implementation, after obtaining the above-mentioned data source identifier, target element and original data, the data is encrypted using an encryption algorithm to ensure the security and confidentiality of the data, and the corresponding first hash value, second hash value and third hash value are calculated.
[0067] As another example, in the process of encrypting data using an encryption algorithm, AES (Advanced Encryption Standard), RSA (Asymmetric Encryption) or SHA (Secure Hash Algorithm) can be used.
[0068] Step S104: Place the above-mentioned first hash value, second hash value and third hash value in the first preset position, second preset position and third preset position of the preset empty matrix respectively, and obtain the hash value matrix corresponding to the above-mentioned original data.
[0069] In a specific implementation, a data structure of an empty matrix is defined in advance to store the hash values. The size and number of the empty matrix correspond to the preset number of hash values. The first hash value calculated is stored in the first preset position of the matrix, the second hash value is stored in the second preset position, and so on. These positions can be specific coordinates of the matrix. The final result is a matrix containing hash values corresponding to the original data.
[0070] The above-mentioned embodiments provided by the embodiments of the present application first acquire the original data and the data source identifier of the original data, perform an encryption algorithm on the data source identifier, and obtain the first preset position of the preset empty matrix. Then, according to the preset encryption level, an encryption algorithm is performed on part of the elements in the original data to calculate the corresponding hash value, and the hash value corresponding to the original data is calculated. Each of the hash values is added to the preset position of the empty matrix to obtain the hash value matrix corresponding to the original data. The complexity of the encryption process is increased, the risk of collision attack inherent in the message digest algorithm is reduced by using a matrix composed of multiple hash values, and the security of the data is improved.
[0071] In order to quickly verify in the subsequent decryption process, in some embodiments, S102 can include steps A1 to B1:
[0072] Step A1: Obtain a preset encryption interval value.
[0073] In a specific implementation, a preset encryption interval value is set. This value is usually a positive integer, which is used to determine the interval of extracting target elements from the original data. In the case of use, the preset encryption interval value is obtained from the target storage location.
[0074] As another example, the encryption interval value can be set through a configuration file or a specific input interface. Such a setting can be flexibly adjusted at runtime.
[0075] Step B1: Extract a number of target elements corresponding to the number of levels from the original data according to the preset encryption interval value.
[0076] In a specific implementation, the encryption interval value obtained in step A1 is used to calculate the specific interval of extracting target elements from the original data. For example, if the encryption interval value is 3, one target element is extracted from every 3 units of data. According to the calculated interval, a preset number of target elements are sequentially extracted from the original data.
[0077] The above embodiment provided by the present application extracts target elements corresponding to the number of levels from the original data according to the preset encryption interval value after obtaining the preset encryption interval value. The target elements are regularly extracted according to the preset encryption interval value for encryption, so that verification can be quickly performed in the subsequent decryption process.
[0078] In order to enable the element filling to be carried out smoothly, in some embodiments, the above B1 can include steps A2 to D2:
[0079] Step A2: Extracting an initial element of the original data.
[0080] In a specific implementation, the first element selected from the original data is read as the initial element. The specific definition of the element depends on the type and structure of the data. For example, for text data, the initial element can be the first character or the first word.
[0081] Step B2: Selecting data positions with an interval of an integer multiple of the encryption interval value from the initial element, and the number of the data positions is equal to the number of levels.
[0082] In a specific implementation, the encryption interval value obtained in step A1 is used to calculate positions with an interval of an integer multiple of the value from the initial element. For example, if the encryption interval value is 3, the 3rd, 6th, 9th, and so on positions are calculated from the initial element, and so on. The number of specific positions to be extracted is equal to the number of levels.
[0083] Step C2: If there is an element in the data position, extracting the element.
[0084] In a specific implementation, for each calculated data position, it is checked whether there is a valid data element in the position. For example, for text data, a valid element can be a character or a word. If there is a valid element in the data position, the element is extracted and stored for subsequent steps.
[0085] Step D2: If there is no element in the data position, the interval number between the data position and the initial element is taken as the element corresponding to the data position, and the element is extracted.
[0086] In a specific implementation, if it is checked in step C2 that there is no valid element in a position, a supplementary data element is generated according to the interval number between the position and the initial element. For example, if the interval number is 3 and the 6th position has no valid element, a new element is generated, and the value of the element can be the interval number between the 6th position and the initial element, such as 6. Then the generated supplementary element is extracted and stored for subsequent processing.
[0087] The above embodiment provided by the application extracts the initial element of the original data, selects the data position with an interval that is an integer multiple of the encryption interval value from the initial element, and the number of the data positions is equal to the level number. If there is an element in the data position, the corresponding element is extracted, if there is no element in the data position, the interval between the data position and the initial element is taken as the element corresponding to the data position, and the element is extracted. In the case that the length of the original data is short and the element cannot be extracted according to the predetermined requirement, the element can be filled to facilitate the filling of the element.
[0088] In order to further improve the security of the data, in some embodiments, after the A1, the method can further include steps A3 to B3:
[0089] Step A3: encrypting the preset encryption interval value to obtain a hash value corresponding to the preset encryption interval value.
[0090] In a specific implementation, the preset encryption interval value is taken as an input, and a hash value is calculated by using a selected hash algorithm. After the hash calculation is completed, a hash value with a fixed length is obtained, that is, the hash value corresponding to the preset encryption interval value.
[0091] Step B3: adding the hash value corresponding to the preset encryption interval value to a fourth preset position of the preset empty matrix.
[0092] In a specific implementation, the hash value corresponding to the preset encryption interval value is stored in the fourth preset position of the empty matrix. Specifically, the hash value can be assigned to the corresponding element in the matrix.
[0093] The above embodiment provided by the application encrypts the preset encryption interval value, and then adds the hash value corresponding to the preset encryption interval value to the fourth preset position of the preset empty matrix. In this way, the preset encryption interval value can be verified in the subsequent decryption process, and the security of the data is further improved.
[0094] In order to further improve the security of the data, in some embodiments, before the preset empty matrix is taken as the hash value matrix corresponding to the original data, the method can further include steps A4 to B4:
[0095] Step A4: encrypting the value of the preset encryption level to obtain a hash value corresponding to the preset encryption level.
[0096] In a specific implementation, the preset encryption level value is taken as an input, and an encryption operation is performed by using a selected encryption algorithm. Then, the hash value corresponding to the preset encryption level is obtained.
[0097] Step B4: add the hash value corresponding to the preset encryption level to a fifth preset position of the preset empty matrix.
[0098] In a specific implementation, it is determined that the hash value is stored in a fifth preset position of the empty matrix. The hash value corresponding to the preset encryption level is assigned to a corresponding element in the matrix.
[0099] The above implementation provided by the embodiments of the present application encrypts the value of the preset encryption level, and then adds the hash value corresponding to the preset encryption level to a fifth preset position of the preset empty matrix. In this way, the value of the preset encryption level can be verified in the subsequent decryption process, and the security of data is further improved.
[0100] To further improve the security of data, in some embodiments, before the preset empty matrix is used as the hash value matrix corresponding to the original data, the method can further include steps A5 to C5:
[0101] Step A5: obtain preset encryption order information, where the preset encryption order information indicates the arrangement order of the encrypted information.
[0102] In a specific implementation, a sequence list or array is defined in advance, which is used to describe the arrangement order of the information to be encrypted in the encryption operation. In the step, the encryption order currently used is obtained from the preset sequence list.
[0103] Step B5: encrypt the preset encryption order information to obtain a hash value corresponding to the preset encryption order information.
[0104] In a specific implementation, the preset encryption order information obtained in step A5 is used as input, and a selected hash algorithm is used for encryption. After the encryption is completed, a hash value is obtained, which is the hash value corresponding to the preset encryption order information.
[0105] Step C5: add the hash value corresponding to the preset encryption order information to a sixth preset position of the preset empty matrix.
[0106] In a specific implementation, the hash value corresponding to the preset encryption order information is stored in a sixth preset position of the empty matrix.
[0107] The above implementation provided by the embodiments of the present application obtains the preset encryption order information, then encrypts the preset encryption order information to obtain a hash value corresponding to the preset encryption order information, and adds the hash value corresponding to the preset encryption order information to a sixth preset position of the preset empty matrix. The preset encryption order information can be verified, and the security of data is further improved.
[0108] To speed up the subsequent analysis, in some embodiments, the above S104 can include steps A6 to C6:
[0109] Step A6: Place the above first hash value into the first row of the preset empty matrix.
[0110] Step B6: Place the above third hash value into the last row of the above preset empty matrix.
[0111] Step C6: Place the above third hash value into the row of the above preset empty matrix which has not been placed with a hash value, to obtain the hash value matrix corresponding to the above original data.
[0112] The above embodiments provided by the embodiments of the present application place the above first hash value into the first row of the preset empty matrix, place the above third hash value into the last row of the above preset empty matrix, and finally place the above third hash value into the row of the above preset empty matrix which has not been placed with a hash value, to obtain the hash value matrix corresponding to the above original data. Each hash value has a fixed position, which can speed up the subsequent analysis.
[0113] In another embodiment of the present application, a data decryption method is provided, as shown in Figure 2 The method includes the following steps S201 to S204.
[0114] Step S201: Extract the first hash value corresponding to the data source identifier from the first preset position of the hash value matrix.
[0115] In specific implementation, after obtaining the hash value matrix, the first hash value stored in the first preset position of the hash value matrix is obtained.
[0116] Step S202: Verify whether the above first hash value matches the preset data source.
[0117] In specific implementation, the first hash value extracted in step S201 is compared with the preset expected hash value, to confirm whether the first hash value matches the expected data source identifier.
[0118] Step S203: In the case of matching with the preset data source, extract the second hash value corresponding to each of the above elements from the second preset position of the hash value matrix, and extract the third hash value corresponding to the original data from the third preset position of the hash value matrix.
[0119] In specific implementation, in the case of matching with the preset data source, the second and third positions of the hash value matrix are accessed to extract the corresponding second and third hash values, respectively.
[0120] Step S204: Verify whether the above second hash value and the third hash value match the expected values.
[0121] In a specific implementation, the second and third hash values extracted in step S203 are compared with expected hash values respectively, to verify whether the second hash value and the third hash value match the expected values.
[0122] Step S205: In the case of matching the expected values, it is determined whether each of the elements corresponds to the original data.
[0123] In a specific implementation, in the case of matching the expected values, it is verified according to a preset data correspondence relationship whether each element is correctly mapped to the expected original data, to determine whether each of the elements corresponds to the original data.
[0124] Step S206: In the case of each of the elements corresponding to the original data, data decryption is completed based on the original data.
[0125] In a specific implementation, in the case of each of the elements corresponding to the original data, the original data extracted from the hash value matrix is used to perform a final data decryption operation, to complete data decryption.
[0126] The above embodiments provided by the application complete data decryption by extracting a first hash value, a second hash value and a third hash value from a hash value matrix respectively, and then verifying the first hash value, the second hash value and the third hash value. By using a matrix composed of multiple hash values, the inherent collision attack risk of the message digest algorithm is reduced, and the security of data is improved.
[0127] In an embodiment of the application, a matrix structure of an encryption matrix is defined first, Figure 3 As shown in the figure, generally, the first row of the matrix is a platform identifier encryption row, the second row of the matrix is an encryption random value encryption row, and the last row of the matrix is an original password encryption row. The row before the original password encryption row is a special processing row after the encryption random value encryption row. In this embodiment, the MD5 algorithm is used, and the number of rows of the generated MD5 encryption matrix is greater than or equal to 3.
[0128] In a specific encryption process, an empty encryption matrix is first constructed. The encryption matrix is a carrier of a password and is an object directly subjected to encryption and decryption operations. Then, a platform identifier is confirmed. The platform identifier can be determined by a user, a platform, a project, etc. and is a general identifier used for encryption and decryption verification within the scope specified in advance. In all encryption and decryption processes, the content related to the platform identifier can be processed preferentially. For content that does not conform to the password logic of the platform identifier, a failure identifier is returned, so as to optimize decryption efficiency.
[0129] Then the platform identification is MD5 encrypted, and the result is placed in the first row of the MD5 matrix. In particular, in the decryption process, the first row content is processed first, and the result is the decryption of the platform identification. Generally, this part is agreed in advance as a regulation, and does not need to be specially identified for judgment processing. Determine the encryption random value N. The encryption random value is a configurable item, which is used as a decryption reference. After MD5 encryption of the encryption random value, the result is placed in the second row of the MD5 matrix. Set the encryption level M. The encryption level is a configurable item, which is used as the number of special processing rows of the encryption matrix. From the first element of the original password, select the cumulative value of 1+N as the subscript of the original password character in turn, a total of M times of encryption level M elements. As the original password selection sequence. When the selected subscript is greater than the length of the original password, the maximum subscript value is used for processing. In this way, M elements are selected from the original password according to the value of the encryption level M. Generate MD5 encryption sequence for each character and place it in the third row to the second last row of the encryption matrix. The special encryption row generation is completed.
[0130] Finally, according to the original information, generate the original password encryption row and place it in the last row of the MD5 encryption matrix to form the matrix, and the encryption is completed.
[0131] In the corresponding decryption process, first take the platform identification and the MD5 matrix header stored in a certain place, decrypt the content of the MD5 matrix header and compare it with the platform identification. If they match, continue to decrypt, if they do not match, decryption fails.
[0132] If they match, continue to decrypt and take the second row of the MD5 matrix, decrypt the content to get the encryption random value. Get the number of rows removed from the two rows at the head and one row at the tail, that is, get the special processing row. Get the original data from the database to compare with the special processing row content.
[0133] Decrypt the special processing row according to the front and back order and the encryption random value, respectively. The result set is obtained after decryption. The result set is compared with the encryption random value based on the original password to get the sequence that meets the order and the original password encryption random value split, which is the special processing row decryption success. Otherwise, decryption fails. Then get the last row of the MD5 encryption matrix. Use MD5 decryption and compare with the original password. If they match, the entire encryption process is successful. Otherwise, decryption fails.
[0134] In some embodiments, the encryption level can be stored in a specified number of rows of the MD5 encryption matrix, and when decrypting, the row can be decrypted in priority to obtain the encryption level. According to the encryption level and the actual number of rows of the MD5 encryption matrix, it is judged whether it conforms to the specification. This method almost does not lose performance and can improve decryption efficiency in some cases. In addition, the order determination row can be placed at the head of the MD5 encryption matrix. The encryption and decryption parties should agree on the meaning of a specific encryption order value in advance, and perform encryption and decryption operations according to the meaning. This method is suitable for scenarios that need to be specified in advance and require more data security, such as system internal, platform internal, etc.
[0135] In some embodiments, when the encrypted random value is accumulated to obtain an index that exceeds the length of the original password, two re-computation methods can be used: modulo method and hash method. Both methods need to be specified in advance by both parties, and when such cases occur during encryption and decryption, reprocessing is performed according to the specification. The above two re-computation methods can be combined with the maximum index method provided in the original scheme to form a method set, and the decryption is performed using the traversal decryption method, and the decryption results are compared based on all decryption results, and the decryption logic is consistent. Higher flexibility.
[0136] Based on the data encryption method provided in the above embodiments, the application also provides a specific implementation of a data encryption device. Please refer to the following embodiments.
[0137] Firstly, referring to Figure 4 The data encryption device 400 provided by the embodiments of the application includes the following modules:
[0138] The acquisition module 401 is configured to acquire original data and a data source identifier of the original data.
[0139] The extraction module 402 is configured to extract a target element corresponding to a number of levels of a preset encryption level from the original data according to the number of levels.
[0140] The encryption module 403 is configured to encrypt the data source identifier, the target element, and the original data respectively, and correspondingly obtain a first hash value, a second hash value, and a third hash value.
[0141] The insertion module 404 is configured to insert the first hash value, the second hash value, and the third hash value into a first preset position, a second preset position, and a third preset position of a preset empty matrix respectively, and obtain a hash value matrix corresponding to the original data.
[0142] The above implementation provided by the embodiment of the present application first acquires original data and a data source identifier of the original data, performs an encryption algorithm on the data source identifier, and obtains a first preset position of a preset empty matrix. Then, according to a preset encryption level, an encryption algorithm is performed on part of elements in the original data, a corresponding hash value is calculated, a hash value corresponding to the original data is calculated, each hash value is added to a preset position of the empty matrix, and a hash value matrix corresponding to the original data is obtained. The complexity of the encryption process is increased, the risk of collision attack inherent in the message digest algorithm is reduced by using a matrix composed of multiple hash values, and the security of the data is improved.
[0143] As an implementation manner of the present application, the data encryption device 400 can further include:
[0144] The acquisition module is configured to acquire a preset encryption interval value.
[0145] The extraction module is configured to extract, according to the preset encryption interval value, a target element corresponding to a number of levels from the original data.
[0146] The above implementation provided by the embodiment of the present application extracts, according to the preset encryption interval value, a target element corresponding to a number of levels from the original data after the preset encryption interval value is acquired. The target element is regularly extracted according to the preset encryption interval value for encryption, so that verification can be quickly performed in a subsequent decryption process.
[0147] As an implementation manner of the present application, the data encryption device 400 can further include:
[0148] The extraction module is configured to extract an initial element of the original data.
[0149] The selection module is configured to select a data position with an interval between the initial element and the data position being an integer multiple of the encryption interval value, and a number of the data positions being equal to the number of levels.
[0150] The extraction module is further configured to extract an element in the data position in a case where the element exists in the data position.
[0151] The extraction module is further configured to, in a case where the element does not exist in the data position, take a number of intervals between the data position and the initial element as an element corresponding to the data position, and extract the element.
[0152] The above embodiment provided by the present application extracts the initial element of the original data, selects the data position with an interval that is an integer multiple of the encryption interval value from the initial element, and the number of the data positions is equal to the level number. If there is an element in the data position, the corresponding element is extracted, if there is no element in the data position, the interval between the data position and the initial element is taken as the element corresponding to the data position, and the element is extracted. In the case that the length of the original data is short and cannot extract the element according to the predetermined requirement, the element can be filled to enable the element filling to be carried out smoothly.
[0153] As an implementation manner of the present application, the data encryption device 400 can further include:
[0154] The encryption module is configured to encrypt the preset encryption interval value to obtain a hash value corresponding to the preset encryption interval value.
[0155] The adding module is configured to add the hash value corresponding to the preset encryption interval value to a fourth preset position of the preset empty matrix.
[0156] The above embodiment provided by the present application encrypts the preset encryption interval value, and then adds the hash value corresponding to the preset encryption interval value to the fourth preset position of the preset empty matrix. In the subsequent decryption process, the preset encryption interval value can be verified, and the security of the data is further improved.
[0157] As an implementation manner of the present application, the data encryption device 400 can further include:
[0158] The encryption module is configured to encrypt the value of the preset encryption level to obtain a hash value corresponding to the preset encryption level.
[0159] The adding module is configured to add the hash value corresponding to the preset encryption level to a fifth preset position of the preset empty matrix.
[0160] The above embodiment provided by the present application encrypts the value of the preset encryption level, and then adds the hash value corresponding to the preset encryption level to the fifth preset position of the preset empty matrix. In the subsequent decryption process, the value of the preset encryption level can be verified, and the security of the data is further improved.
[0161] As an implementation manner of the present application, the data encryption device 400 can further include:
[0162] The obtaining module is configured to obtain preset encryption sequence information, and the preset encryption sequence information indicates the arrangement sequence of the encrypted information.
[0163] The encryption module is configured to encrypt the preset encryption sequence information to obtain a hash value corresponding to the preset encryption sequence information.
[0164] The adding module is configured to add the hash value corresponding to the preset encryption sequence information to a sixth preset position of the preset empty matrix.
[0165] The above-mentioned embodiments provided by the present application obtain the preset encryption sequence information, then encrypt the preset encryption sequence information to obtain a hash value corresponding to the preset encryption sequence information, and add the hash value corresponding to the preset encryption sequence information to a sixth preset position of the preset empty matrix. The preset encryption sequence information can be verified, and the security of data is further improved.
[0166] As an implementation manner of the present application, the data encryption device 400 can further include:
[0167] The placing module is configured to place the first hash value into a first row of the preset empty matrix.
[0168] The placing module is further configured to place the third hash value into a last row of the preset empty matrix.
[0169] The placing module is further configured to place the third hash value into a row of the preset empty matrix in which no hash value is placed, to obtain a hash value matrix corresponding to the original data.
[0170] The above-mentioned embodiments provided by the present application place the first hash value into a first row of the preset empty matrix, place the third hash value into a last row of the preset empty matrix, and finally place the third hash value into a row of the preset empty matrix in which no hash value is placed, to obtain a hash value matrix corresponding to the original data. Each hash value has a fixed position, and the speed of subsequent analysis can be accelerated.
[0171] Each module in the data encryption device provided by the embodiments of the present application can implement each step in the above-mentioned data encryption method and achieve the corresponding effects. For brevity and conciseness, no further description is given here.
[0172] Figure 5 A structure schematic diagram of a data encryption hardware provided by the embodiments of the present application is shown.
[0173] The data encryption device can include a processor 501 and a memory 502 in which computer program instructions are stored.
[0174] In particular, the processor 501 can include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to perform one or more of the embodiments of the present application.
[0175] The memory 502 can include mass storage for data or instructions. As an example and not by way of limitation, the memory 502 can include a hard disk drive (HDD), a floppy disk drive, flash memory, an optical disc (e.g., a compact disc (CD) or a digital versatile disc (DVD)), a solid-state drive (SSD), a USB drive, or a combination of two or more of these. Where appropriate, the memory 502 can include removable or non-removable (or fixed) media, where appropriate. The memory 502 can be internal or external to the integrated gateway disaster recovery device. In particular embodiments, the memory 502 is non-volatile, solid-state memory.
[0176] The memory can include read-only memory (ROM), random-access memory (RAM), magnetic disk storage mediums, optical storage mediums, flash memory devices, electrical, optical, or other physical / tangible memory storage devices. Thus, in general, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software that, when executed (by one or more processors), is operable to perform operations described with reference to the data encryption method according to any one of the embodiments of the present disclosure.
[0177] The processor 501 implements any one of the data encryption methods in the above embodiments by reading and executing computer program instructions stored in the memory 502.
[0178] In one example, the data encryption device can further include a communication interface 503 and a bus 510. As shown, the processor 501, the memory 502, and the communication interface 503 are connected through the bus 510 and complete communication among each other. Figure 5
[0179] The communication interface 503 is mainly used to realize the communication among the modules, devices, units and / or equipment in the embodiments of the present application.
[0180] Bus 510 includes hardware, software, or both, to couple components of the online data traffic metering device to each other and to couple components to other components within the online data traffic metering device. While bus 510 is shown for the sake of clarity as a single bus, bus 510 can include one or more buses operating together, serially, in parallel, etc. Bus 510 can include any suitable bus or interconnect, including a memory bus, a peripheral bus, an external bus, a serial bus, a parallel bus, etc. or a combination of one or more of the above. Bus 510 can include any suitable bus or interconnect, including an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infineon
[0181] In addition, the embodiments of the present application can provide a computer storage medium to implement the method of data encryption in the above embodiments. The computer storage medium stores computer program instructions; the computer program instructions are executed by a processor to implement any of the methods of data encryption in the above embodiments.
[0182] The embodiments of the present application also provide a computer program product, comprising a computer program, the computer program is executed by a processor to implement any of the methods of data encryption in the above embodiments.
[0183] It should be understood that the present application is not limited to the particular configurations and processes described above and shown in the figures. Detailed descriptions of known methods are omitted for the sake of brevity. In the above embodiments, several specific steps are described and shown as examples. However, the method processes of the present application are not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order of the steps, after understanding the spirit of the present application.
[0184] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0185] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0186] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0187] The above merely describes a specific implementation of the present application. Those skilled in the art can clearly understand the specific working processes of the system, modules and units described above for the convenience and brevity of description, and can refer to the corresponding processes in the foregoing method embodiments, which will not be described herein again. It should be understood that the protection scope of the present application is not limited to this, and any person skilled in the art can easily think of various equivalent modifications or replacements within the technical range disclosed by the present application, and these modifications or replacements should be covered within the protection scope of the present application.
Claims
1. A data encryption method characterized by, The method comprises: obtaining original data and a data source identifier of the original data; extracting a target element corresponding to a number of levels of a preset encryption level from the original data according to the number of levels; encrypting the data source identifier, the target element and the original data respectively to obtain a first hash value, a second hash value and a third hash value; placing the first hash value, the second hash value and the third hash value into a first preset position, a second preset position and a third preset position of a preset empty matrix respectively to obtain a hash value matrix corresponding to the original data.
2. The data encryption method of claim 1, wherein, The method comprises: obtaining a preset encryption interval value; extracting a target element corresponding to the number of levels from the original data according to the preset encryption interval value.
3. The data encryption method of claim 2, wherein, The method comprises: extracting an initial element of the original data; selecting a data position with an interval being an integer multiple of the encryption interval value from the initial element, the number of data positions being equal to the number of levels; extracting an element in the data position if the element exists in the data position; extracting an element corresponding to the data position as an interval between the data position and the initial element if the element does not exist in the data position.
4. The data encryption method of claim 2, wherein, After obtaining the preset encryption interval value, the method further comprises: encrypting the preset encryption interval value to obtain a hash value corresponding to the preset encryption interval value; adding the hash value corresponding to the preset encryption interval value to a fourth preset position of a preset empty matrix.
5. The data encryption method of claim 1, wherein, Before placing the preset empty matrix as the hash value matrix corresponding to the original data, the method further comprises: encrypting the value of the preset encryption level to obtain a hash value corresponding to the preset encryption level; adding the hash value corresponding to the preset encryption level to a fifth preset position of a preset empty matrix.
6. The data encryption method of claim 1, wherein, Before placing the preset empty matrix as the hash value matrix corresponding to the original data, the method further comprises: obtaining preset encryption sequence information, the preset encryption sequence information indicating an arrangement sequence of encrypted information; encrypting the preset encryption sequence information to obtain a hash value corresponding to the preset encryption sequence information; adding the hash value corresponding to the preset encryption sequence information to a sixth preset position of a preset empty matrix.
7. The data encryption method according to any one of claims 1 to 6, characterized in that, The method comprises: placing the first hash value into a first row of a preset empty matrix; placing the third hash value into a last row of the preset empty matrix; placing the third hash value into a row of the preset empty matrix without placing a hash value to obtain the hash value matrix corresponding to the original data.
8. A data decryption method characterized by, The method comprises: extracting a first hash value corresponding to a data source identifier from a first preset position of a hash value matrix; verify whether the first hash value matches a preset data source; extract a second hash value corresponding to each element from a second preset position of the hash value matrix and a third hash value corresponding to the original data from a third preset position of the hash value matrix in the case of matching the preset data source; the element is extracted from the original data according to a number of levels of a preset encryption level, and the number of elements corresponds to the number of levels of the preset encryption level; verify whether the second hash value and the third hash value match expected values; in the case of matching the expected values, determine whether each element corresponds to the original data; in the case of each element corresponding to the original data, complete data decryption based on the original data.
9. A data encryption device, characterized by comprising: The device comprises: an acquisition module configured to acquire original data and a data source identifier of the original data; an extraction module configured to extract a target element corresponding to a number of levels of a preset encryption level from the original data; an encryption module configured to respectively encrypt the data source identifier, the target element, and the original data, and correspondingly obtain a first hash value, a second hash value, and a third hash value; a placement module configured to place the first hash value, the second hash value, and the third hash value into a first preset position, a second preset position, and a third preset position of a preset empty matrix, respectively, to obtain a hash value matrix corresponding to the original data.
10. A data encryption device, characterized by comprising: The device comprises a processor and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the data encryption method of any one of claims 1-7.
11. A computer readable storage medium, characterized in that, The computer readable storage medium stores computer program instructions, and the computer program instructions are executed by the processor to implement the data encryption method of any one of claims 1-7.
12. A computer program product, characterised in that, The instructions in the computer program product are executed by the processor of the electronic device, so that the electronic device executes the data encryption method of any one of claims 1-7.
Citation Information
Patent Citations
Secure data parser method and system
CN101375284A
Image encryption method and device, storage medium and electronic equipment
CN116484408A