Data encryption method and device, equipment, storage medium and product
By performing multi-level encryption and hash value combination on the data, the problem of insufficient security of the MD5 algorithm in collision attacks is solved, and the overall security of the data is improved.
Patent Information
- Application Number
- CN202410989229.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2044-07-22
AI Technical Summary
The existing MD5 algorithm is insecure in the face of collision attacks and cannot effectively deal with the problem of failing file consistency verification.
By obtaining the original data and data source identifiers, the target element is extracted according to the preset encryption hierarchy number, and the data source identifier, target element and original data are encrypted, multiple hash values are generated, and combined into a matrix to improve encryption complexity and reduce the Collision attack risk.
By increasing the complexity of the encryption process and using a matrix of multiple hash values, data security is significantly improved and the collision attack risk inherent in the message digest algorithm is reduced.
Smart Images

Figure CN119030704A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security technology, and in particular to a data encryption method, device, equipment, storage medium and product. Background Art
[0002] Message-Digest Algorithm 5 (MD5) is a cryptographic hash function that can convert data into a 128-bit (16-byte) hash value. This hash value is used to ensure the integrity and consistency of information transmission. MD5 can generate a "digital fingerprint" for any file, and a small change to the file will directly lead to a huge change in the digital fingerprint. Therefore, it is widely used in consistency verification of files of various data types such as text, audio and video to prevent files from being tampered with. The MD5 algorithm can also be used to generate fingerprint information of a message to verify the integrity and source of the message.
[0003] However, the current MD5 algorithm has a fixed operation process, which makes its encryption process easy to predict and crack. For example, the MD5 algorithm has a fundamental problem of being unable to effectively deal with collision attacks. A collision attack is to find two different input values that produce the same hash value, thus making the MD5 algorithm's consistency check of the file invalid. The existing MD5 algorithm is not secure enough. Summary of the invention
[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] According to the number of preset encryption levels, extracting target elements corresponding to the number of levels from the original data;
[0008] Encrypting the data source identifier, the target element, and the original data respectively, and obtaining a first hash value, a second hash value, and a third hash value accordingly;
[0009] The first hash value, the second hash value and the third hash value are placed in 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 implementations, extracting, according to the number of levels of the preset encryption levels, target elements of a number corresponding to the number of levels from the original data includes:
[0011] Get the preset encryption interval value;
[0012] According to a preset encryption interval value, target elements of a number corresponding to the number of levels are extracted from the original data.
[0013] In some possible implementations, extracting a number of target elements corresponding to the number of levels from the original data according to a preset encryption interval value includes:
[0014] Extract the initial elements of the original data;
[0015] Selecting data positions whose intervals from the initial element are integer multiples of the encryption interval value, the number of the data positions being equal to the number of levels;
[0016] If an element exists in the data position, extracting the element;
[0017] In the case where there is no element at the data position, the number of intervals between the data position and the initial element is taken as the element corresponding to the data position, and the element is extracted.
[0018] In some possible implementations, after 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] The hash value corresponding to the preset encryption interval value is added to the fourth preset position of the preset empty matrix.
[0021] In some possible implementations, before using the preset empty matrix as a 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] The hash value corresponding to the preset encryption level is added to the fifth preset position of the preset empty matrix.
[0024] In some possible implementations, before using the preset empty matrix as a hash value matrix corresponding to the original data, the method further includes:
[0025] Acquire preset encryption sequence information, where the preset encryption sequence information indicates the arrangement sequence of the encrypted information;
[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 the sixth preset position of the preset empty matrix.
[0028] In some possible implementations, 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 includes:
[0029] Placing the first hash value into the first row of a preset empty matrix;
[0030] Placing the third hash value into the last row of the preset empty matrix;
[0031] The third hash value is placed in a row of the preset empty matrix where no hash value is placed, to obtain a hash value matrix corresponding to the original data.
[0032] In a second aspect, the present application provides a data decryption method, comprising:
[0033] Extracting a first hash value corresponding to the data source identifier from a first preset position of the hash value matrix;
[0034] Verifying whether the first hash value matches a preset data source;
[0035] In the case of matching with the preset data source, extracting the second hash value corresponding to each of the elements from the second preset position of the hash value matrix, and extracting the third hash value corresponding to the original data from the third preset position of the hash value matrix;
[0036] Verifying whether the second hash value and the third hash value match expected values;
[0037] In the case of matching with the expected value, determining whether each of the elements corresponds to the original data;
[0038] When each of the elements corresponds 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, the device comprising:
[0040] An acquisition module, used to acquire original data and a data source identifier of the original data;
[0041] An extraction module, configured to extract target elements of a number corresponding to the number of levels of a preset encryption level from the original data;
[0042] An encryption module, used to encrypt the data source identifier, the target element and the original data respectively, and obtain a first hash value, a second hash value and a third hash value accordingly;
[0043] The inserting module is used to insert the first hash value, the second hash value and the third hash value into the first preset position, the second preset position and the third preset position of the preset empty matrix respectively, so as to obtain the hash value matrix corresponding to the original data.
[0044] In a fourth aspect, the present application provides a data encryption device, comprising: 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 having computer program instructions stored thereon, and the computer program instructions, when executed by a processor, implement the data encryption method as described above.
[0046] In a sixth aspect, the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device performs the data encryption method described above.
[0047] The data encryption method, device, equipment, storage medium and product provided in the embodiments of the present application first obtain the original data and the data source identifier of the original data, execute the encryption algorithm on the data source identifier, and add the obtained data to the first preset position of the preset empty matrix. Then, according to the preset encryption level, the encryption algorithm is executed on some elements in the original data to calculate the corresponding hash value, and then the hash value corresponding to the original data is calculated, and 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, and by using a matrix composed of multiple hash values, the risk of collision attacks inherent in the message digest algorithm is reduced, and the security of the data is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The present application can be better understood from the following description of the specific embodiments of the present application in conjunction with the accompanying drawings, in which:
[0049] Other features, objects and advantages of the present application will become more apparent by reading the following detailed description of non-limiting embodiments with reference to the accompanying drawings, in which the same or similar reference numerals represent the same or similar features.
[0050] Figure 1 is a flow chart of a data encryption method provided by an embodiment of the present application;
[0051] Figure 2 is a flow chart of a data decryption method provided by an embodiment of the present application;
[0052] Figure 3 is a schematic diagram of components of an encryption matrix provided by another embodiment of the present application;
[0053] Figure 4 It is a structural schematic diagram of a data encryption device provided by an embodiment of the present application;
[0054] Figure 5 It is a schematic diagram of the hardware structure 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. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.
[0056] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0057] In order to solve the problems of the prior art, the embodiments of the present application provide a data encryption method, device, equipment, storage medium and product. The data encryption method provided by the embodiments of the present application is first introduced below.
[0058] Figure 1 The flowchart of a data encryption method provided by an embodiment of the present application is shown. This method can be executed by the above-mentioned data encryption device, such as Figure 1 As shown, the method includes the following steps S101 to S104.
[0059] Step S101: Acquire original data and a data source identifier of the original data.
[0060] In a specific implementation, the original data can be obtained through network request, file reading, database query, etc. The data can be of any type, such as text, numbers, images, videos, etc. According to the data source of the above 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 may be a file path, a uniform resource locator (URL), a primary key of a database record, or the like.
[0062] Step S102: according to the number of preset encryption levels, extracting target elements corresponding to the number of levels from the original data.
[0063] In a specific implementation, the encryption level is preset to control the number of target elements to be extracted. For example, if it is preset to 3, 3 target elements need to be extracted from the original data. Then, target elements corresponding to the number of levels are extracted from the original data.
[0064] As another example, the method of extracting target elements depends on the type of data. For text data, it can be to extract a specified number of words or sentences; for image data, it can be to extract a specified number of pixel regions or features; for video data, it can be to extract a specified number of frames. These extraction processes need to ensure the integrity and representativeness of the data.
[0065] Step S103: Encrypt the data source identifier, target element and original data respectively, and obtain a first hash value, a second hash value and a third hash value accordingly.
[0066] In a specific implementation, after obtaining the above-mentioned data source identifier, target element and original data, an encryption algorithm is used to encrypt the data to ensure the security and confidentiality of the data, and the corresponding first hash value, second hash value and third hash value are obtained by calculation.
[0067] As another example, in the process of encrypting data using an encryption algorithm, AES (Advanced Encryption Standard), RSA (asymmetric encryption), SHA (Secure Hash Algorithm), etc. may be used.
[0068] Step S104: placing the first hash value, the second hash value and the third hash value into the first preset position, the second preset position and the third preset position of the preset empty matrix respectively, to obtain a hash value matrix corresponding to the original data.
[0069] In a specific implementation, a data structure of an empty matrix is defined in advance to store hash values. The size and number of the empty matrix correspond to the number of preset hash values. The calculated first hash value 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 the hash values corresponding to the original data.
[0070] The above implementation method provided by the embodiment of the present application first obtains the original data and the data source identifier of the original data, executes the encryption algorithm on the data source identifier, and adds the obtained data to the first preset position of the preset empty matrix. Then, according to the preset encryption level, the encryption algorithm is executed on some elements in the original data to calculate the corresponding hash value, and then the hash value corresponding to the original data is calculated, and each of the above 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, and by using a matrix composed of multiple hash values, the risk of collision attacks inherent in the message digest algorithm is reduced, and the security of the data is improved.
[0071] In order to quickly perform verification in the subsequent decryption process, in some implementations, the above S102 may include steps A1 to B1:
[0072] Step A1: Obtain a preset encryption interval value.
[0073] In the specific implementation, an encryption interval value is preset. This value is usually a positive integer, which is used to determine the interval for extracting target elements from the original data. When it is needed, 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: according to a preset encryption interval value, extract target elements corresponding to the number of levels from the original data.
[0076] In a specific implementation, the encryption interval value obtained in step A1 is used to calculate the specific interval at which the target element needs to be extracted from the original data. For example, if the encryption interval value is 3, a target element is extracted from the data every 3 units. According to the calculated interval, a preset number of target elements are sequentially extracted from the original data.
[0077] The above implementation provided by the embodiment of 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 and encrypted according to the preset encryption interval value, so that verification can be quickly performed in the subsequent decryption process.
[0078] In order to allow the element filling to proceed smoothly, in some implementations, the above B1 may include steps A2 to D2:
[0079] Step A2: Extract the initial elements of the original data.
[0080] In a specific implementation, the first element is read from the selected raw data 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: Select data positions whose intervals from the initial elements are integer multiples of the encryption interval value, 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 the positions whose intervals from the initial element are integer multiples of the value. For example, if the encryption interval value is 3, starting from the initial element, the 3rd, 6th, 9th, and so on positions are calculated, and so on. The specific number of positions to be extracted is equal to the number of levels mentioned above.
[0083] Step C2: If an element exists in the above data position, extract the above element.
[0084] In the specific implementation, for each calculated data position, check whether there is a valid data element at that position. For example, for text data, a valid element may be a character or a word. If there is a valid element at the data position, extract it and store it for use in subsequent steps.
[0085] Step D2: When no element exists in the data position, the number of intervals between the data position and the initial element is used as the element corresponding to the data position, and the element is extracted.
[0086] In a specific implementation, if it is detected in step C2 that a certain position does not have a valid element, a supplementary data element is generated according to the number of intervals between the position and the initial element. For example, if the number of intervals is 3 and there is no valid element at the 6th position, a new element is generated, and its value may be the number of intervals between the 6th position and the initial element, such as 6. The generated supplementary element is then extracted and stored for subsequent processing.
[0087] The above implementation provided by the embodiment of the present application is to select data positions whose intervals with the above initial elements are integer multiples of the above encryption interval value after extracting the initial elements of the original data, and the number of the above data positions is equal to the number of the above levels. If there is an element in the above data position, the corresponding element is extracted. If there is no element in the above data position, the number of intervals between the above data position and the above initial element is used as the element corresponding to the above data position, and the above element is extracted. When the length of the original data is short and the elements cannot be extracted according to the predetermined requirements, padding can be performed to allow the element filling to proceed smoothly.
[0088] In order to further improve the security of data, in some embodiments, after the above A1, the above method may further include steps A3 to B3:
[0089] Step A3: Encrypt the above-mentioned preset encryption interval value to obtain a hash value corresponding to the above-mentioned preset encryption interval value.
[0090] In a specific implementation, the preset encryption interval value is used as input, and the selected hash algorithm is used to calculate the hash value. After the hash calculation is completed, a hash value of a fixed length is obtained, which is the hash value corresponding to the preset encryption interval value.
[0091] Step B3: Add the hash value corresponding to the preset encryption interval value to the 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 implementation provided by the embodiment of 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 this way, in the subsequent decryption process, the preset encryption interval value can be verified, further improving the security of the data.
[0094] In order to further improve the security of data, in some implementations, before using the preset empty matrix as the hash value matrix corresponding to the original data, the method may further include steps A4 to B4:
[0095] Step A4: Encrypt 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 used as input, and the selected encryption algorithm is used to perform encryption operations, thereby obtaining a hash value corresponding to the preset encryption level.
[0097] Step B4: Add the hash value corresponding to the preset encryption level to the fifth preset position of the preset empty matrix.
[0098] In a specific implementation, it is determined to store the hash value in the fifth preset position of the empty matrix. The hash value corresponding to the preset encryption level is assigned to the corresponding element in the matrix.
[0099] The above implementation provided by the embodiment 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 the fifth preset position of the preset empty matrix. In this way, in the subsequent decryption process, the value of the preset encryption level can be verified, further improving the security of the data.
[0100] In order to further improve the security of data, in some embodiments, before using the preset empty matrix as the hash value matrix corresponding to the original data, the method may further include steps A5 to C5:
[0101] Step A5: Obtain preset encryption sequence information, where the preset encryption sequence information indicates the arrangement sequence of the encrypted information.
[0102] In a specific implementation, a sequence list or array is predefined to describe the order of arrangement of information to be encrypted in the encryption operation. When the step is executed, the currently used encryption sequence is obtained from the preset sequence list.
[0103] Step B5: Encrypt the preset encryption sequence information to obtain a hash value corresponding to the preset encryption sequence information.
[0104] In a specific implementation, the preset encryption sequence information obtained in step A5 is used as input, and the selected hash algorithm is used to perform an encryption operation. After the encryption is completed, a hash value is obtained, which is the hash value corresponding to the preset encryption sequence information.
[0105] Step C5: adding the hash value corresponding to the preset encryption sequence information to the sixth preset position of the preset empty matrix.
[0106] In a specific implementation, the hash value corresponding to the preset encryption sequence information is stored in the sixth preset position of the empty matrix.
[0107] The above implementation provided by the embodiment of the present application obtains the preset encryption sequence information, and then encrypts the preset encryption sequence information to obtain the hash value corresponding to the preset encryption sequence information, and adds the hash value corresponding to the preset encryption sequence information to the sixth preset position of the preset empty matrix. The preset encryption sequence information can be verified to further improve the security of the data.
[0108] In order to speed up the subsequent analysis, in some implementations, the above S104 may include steps A6 to C6:
[0109] Step A6: Place the first hash value into the first row of a preset empty matrix.
[0110] Step B6: placing the third hash value into the last row of the preset empty matrix.
[0111] Step C6: placing the third hash value into the row in the preset empty matrix where no hash value is placed, to obtain a hash value matrix corresponding to the original data.
[0112] The implementation method provided in the embodiment of the present application places the first hash value into the first row of a preset empty matrix, places the third hash value into the last row of the preset empty matrix, and finally places the third hash value into the row in the preset empty matrix where no hash value is placed, to obtain a hash value matrix corresponding to the original data, in which each hash value has a fixed position, and can speed up subsequent parsing.
[0113] In another embodiment of the present application, a data decryption method is provided, such as Figure 2 As shown, the method includes the following steps S201 to S204.
[0114] Step S201: extracting a first hash value corresponding to a data source identifier from a first preset position of a hash value matrix.
[0115] In a specific implementation, after the hash value matrix is obtained, the first preset position of the hash value matrix is obtained to obtain the first hash value stored there.
[0116] Step S202: Verify whether the first hash value matches a preset data source.
[0117] In a specific implementation, the first hash value extracted in step S201 is compared with a preset expected hash value to confirm whether the first hash value matches the expected data source identifier.
[0118] Step S203: When the data source matches the preset data source, the second hash value corresponding to each of the above elements is extracted from the second preset position of the hash value matrix, and the third hash value corresponding to the original data is extracted from the third preset position of the hash value matrix.
[0119] In a specific implementation, when matching with a preset data source, the second and third positions of the hash value matrix are accessed to extract the corresponding second hash value and third hash value respectively.
[0120] Step S204: verify whether the second hash value and the third hash value match the expected value.
[0121] In a specific implementation, the second and third hash values extracted in step S203 are respectively compared with the expected hash values to verify whether the second hash value and the third hash value match the expected values.
[0122] Step S205: When the expected value matches the expected value, determine whether each of the above elements corresponds to the above original data.
[0123] In a specific implementation, when the expected value matches, it is verified whether each element is correctly mapped to the expected original data according to a preset data correspondence relationship, and it is determined whether each of the above elements corresponds to the above original data.
[0124] Step S206: When each of the above elements corresponds to the above original data, data decryption is completed based on the above original data.
[0125] In a specific implementation, when each of the above elements corresponds to the above original data, the original data extracted from the hash value matrix is used to perform a final data decryption operation to complete the data decryption.
[0126] The above implementation provided by the embodiment of the present application extracts the first hash value, the second hash value and the third hash value from the hash value matrix respectively, and then verifies the first hash value, the second hash value and the third hash value, thereby completing data decryption. By using a matrix composed of multiple hash values, the inherent risk of collision attacks in the message digest algorithm is reduced, and the security of data is improved.
[0127] In one embodiment of the present application, the matrix structure of the encryption matrix is first defined. Figure 3 As shown, generally, the first row of the matrix is the platform identification encryption row, the second row of the matrix is the encryption row of the encrypted random value, and the last row of the matrix is the original password encryption row. After the encryption row of the encrypted random value, the row before the original password encryption row is a special processing 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 the specific encryption process, first build an empty encryption matrix. As the carrier of the password, the encryption matrix is the object for direct encryption and decryption operations. Then confirm the platform identifier. The platform identifier can be determined by the user, platform, project, etc. It is a universal identifier for encryption and decryption verification used within this scope that is specified in advance. In all encryption and decryption processes, the content related to the platform identifier can be processed first. For content that does not conform to the platform identifier password logic, a failure indicator is returned. This optimizes the decryption efficiency.
[0129] Then perform MD5 encryption on the platform logo and place the result in the first row of the MD5 matrix. In particular, during the decryption process, the first row of content is processed first, and the result is the decryption of the platform logo. Generally, this part can be agreed upon in advance as a regulation, and no special identification is required for judgment and processing. Determine the encrypted random value N. The encrypted random value is a configurable item and serves as a reference for decryption. After the encrypted random value is encrypted by MD5, the result is placed in the second row of the MD5 matrix. Set the encryption level M. The encryption level is a configurable item and serves as the number of rows of the encryption matrix for special processing. Starting from the first element of the original password, select the original password characters with the accumulated value of 1+N as the subscript in turn, and select the encryption level M times, that is, M elements. As the original password screening 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 an MD5 encryption sequence for each character and place them in the third to the second to last row of the encryption matrix, and the special encryption row is generated.
[0130] Finally, based on the original information, the original password encryption row is generated and placed in the last row of the MD5 encryption matrix to form a matrix, and the encryption is completed.
[0131] In the corresponding decryption process, the platform identifier and MD5 matrix header stored somewhere are first obtained, the content of the MD5 matrix header is decrypted and compared with the platform identifier. If they match, decryption continues; if not, decryption fails.
[0132] If they match, continue to decrypt and get the second row of the MD5 matrix. Decrypt the content to get the encrypted random value. Get the number of rows after removing the first two rows and the last one row, that is, get the special processing row. Get the original data from the database and compare it with the content of the special processing row.
[0133] Decrypt the special processing rows according to the order and encrypted random values. After decryption, get the result set. Compare the result set with the encrypted random value based on the original password. If the sequence is in order and the encrypted random value split of the original password is obtained, the special processing row is successfully decrypted. Otherwise, the decryption fails. Then get the last row of the MD5 encryption matrix. Use MD5 to decrypt and compare with the original password. If it is consistent, the entire encryption process is successfully completed. Otherwise, the decryption fails.
[0134] In some embodiments, the encryption level can be stored in a specified number of rows of the MD5 encryption matrix. When decrypting, this row can be appropriately prioritized 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 meets the specifications. This method has almost no performance loss and can improve the 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 in advance on the meaning of the specific encryption sequence value, and perform encryption and decryption operations according to this meaning. This method is suitable for scenarios that need to be specified in advance and require more data security. Such as scenarios within the system and within the platform.
[0135] In some embodiments, when the encrypted random values are accumulated to obtain a subscript that exceeds the length of the original password, two specific recalculation methods can be used: remainder method and hash method. Both methods need to be stipulated by both parties in advance, and when such situations are encountered during the encryption and decryption process, they shall be reprocessed in accordance with the regulations. The above two recalculation methods can be combined with the maximum subscript method that comes with the original solution into a method set, and the traversal decryption method is used for decryption. Comparison is performed based on all decryption results, and there are situations that meet the requirements and meet the decryption logic. It is more flexible.
[0136] Based on the data encryption method provided in the above embodiment, the present application also provides a specific implementation of the data encryption device. Please refer to the following embodiment.
[0137] See first Figure 4 The data encryption device 400 provided in the embodiment of the present application includes the following modules:
[0138] The acquisition module 401 is used to acquire original data and a data source identifier of the original data.
[0139] The extraction module 402 is used to extract target elements of a number corresponding to the number of preset encryption levels from the original data.
[0140] The encryption module 403 is used to encrypt the data source identifier, the target element and the original data respectively, and obtain a first hash value, a second hash value and a third hash value accordingly.
[0141] The inserting module 404 is used to insert the first hash value, the second hash value and the third hash value into the first preset position, the second preset position and the third preset position of the preset empty matrix respectively, so as to obtain the hash value matrix corresponding to the original data.
[0142] The above implementation method provided by the embodiment of the present application first obtains the original data and the data source identifier of the original data, executes the encryption algorithm on the data source identifier, and adds the obtained data to the first preset position of the preset empty matrix. Then, according to the preset encryption level, the encryption algorithm is executed on some elements in the original data to calculate the corresponding hash value, and then the hash value corresponding to the original data is calculated, and each of the above 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, and by using a matrix composed of multiple hash values, the risk of collision attacks inherent in the message digest algorithm is reduced, and the security of the data is improved.
[0143] As an implementation of the present application, the data encryption device 400 may further include:
[0144] The acquisition module is used to obtain the preset encryption interval value.
[0145] The extraction module is used to extract target elements of a number corresponding to the number of levels from the original data according to a preset encryption interval value.
[0146] The above implementation provided by the embodiment of 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 and encrypted according to the preset encryption interval value, so that verification can be quickly performed in the subsequent decryption process.
[0147] As an implementation of the present application, the data encryption device 400 may further include:
[0148] The extraction module is used to extract the initial elements of the original data.
[0149] The selection module is used to select data positions whose intervals with the initial elements are integer multiples of the encryption interval value, and the number of the data positions is equal to the number of levels.
[0150] The extraction module is also used to extract the above element when the element exists in the above data position.
[0151] The extraction module is further used to, when there is no element in the data position, use the number of intervals between the data position and the initial element as the element corresponding to the data position, and extract the element.
[0152] The above implementation provided by the embodiment of the present application is to select data positions whose intervals with the above initial elements are integer multiples of the above encryption interval value after extracting the initial elements of the original data, and the number of the above data positions is equal to the number of levels. If there is an element in the above data position, the corresponding element is extracted. If there is no element in the above data position, the number of intervals between the above data position and the above initial element is used as the element corresponding to the above data position, and the above element is extracted. In the case where the length of the original data is short and the elements cannot be extracted according to the predetermined requirements, padding can be performed so that the element filling can proceed smoothly.
[0153] As an implementation of the present application, the data encryption device 400 may further include:
[0154] The encryption module is used to encrypt the above-mentioned preset encryption interval value to obtain a hash value corresponding to the above-mentioned preset encryption interval value.
[0155] The adding module is used to add the hash value corresponding to the above-mentioned preset encryption interval value to the fourth preset position of the preset empty matrix.
[0156] The above implementation provided by the embodiment of 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 this way, in the subsequent decryption process, the preset encryption interval value can be verified, further improving the security of the data.
[0157] As an implementation of the present application, the data encryption device 400 may further include:
[0158] The encryption module is used 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 used to add the hash value corresponding to the above-mentioned preset encryption level to the fifth preset position of the preset empty matrix.
[0160] The above implementation provided by the embodiment 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 the fifth preset position of the preset empty matrix. In this way, in the subsequent decryption process, the value of the preset encryption level can be verified, further improving the security of the data.
[0161] As an implementation of the present application, the data encryption device 400 may further include:
[0162] The acquisition module is used to acquire preset encryption sequence information, where the preset encryption sequence information represents the arrangement sequence of the encrypted information.
[0163] The encryption module is used to encrypt the preset encryption sequence information to obtain a hash value corresponding to the preset encryption sequence information.
[0164] The adding module is used to add the hash value corresponding to the above-mentioned preset encryption sequence information to the sixth preset position of the preset empty matrix.
[0165] The above implementation provided by the embodiment of the present application obtains the preset encryption sequence information, and then encrypts the preset encryption sequence information to obtain the hash value corresponding to the preset encryption sequence information, and adds the hash value corresponding to the preset encryption sequence information to the sixth preset position of the preset empty matrix. The preset encryption sequence information can be verified to further improve the security of the data.
[0166] As an implementation of the present application, the data encryption device 400 may further include:
[0167] An inserting module, used for inserting the first hash value into the first row of a preset empty matrix;
[0168] The inserting module is further used to insert the third hash value into the last row of the preset empty matrix;
[0169] The inserting module is further used to insert the third hash value into the row in which no hash value is inserted in the preset empty matrix, so as to obtain the hash value matrix corresponding to the original data.
[0170] The implementation method provided in the embodiment of the present application places the first hash value into the first row of a preset empty matrix, places the third hash value into the last row of the preset empty matrix, and finally places the third hash value into the row in the preset empty matrix where no hash value is placed, to obtain a hash value matrix corresponding to the original data, in which each hash value has a fixed position, and can speed up subsequent parsing.
[0171] Each module in the data encryption device provided in the embodiment of the present application can implement each step in the above-mentioned data encryption method and achieve the corresponding effect. For the sake of concise description, it will not be repeated here.
[0172] Figure 5 A schematic diagram of the structure of the data encryption hardware provided in an embodiment of the present application is shown.
[0173] The data encryption device may include a processor 501 and a memory 502 storing computer program instructions.
[0174] Specifically, the processor 501 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0175] The memory 502 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 502 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 502 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 502 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 502 is a non-volatile solid-state memory.
[0176] The memory may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Thus, typically, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the 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 may further include a communication interface 503 and a bus 510. Figure 5 As shown, the processor 501, the memory 502, and the communication interface 503 are connected via a bus 510 and communicate with each other.
[0179] The communication interface 503 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0180] Bus 510 includes hardware, software or both, and the parts of online data flow billing equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front-end bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 510 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the present application considers any suitable bus or interconnection.
[0181] In addition, in combination with the data encryption method in the above embodiment, the embodiment of the present application can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by the processor, any one of the data encryption methods in the above embodiment is implemented.
[0182] An embodiment of the present application also provides a computer program product, including a computer program, which implements any one of the data encryption methods in the above embodiments when the computer program is processed and executed.
[0183] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is 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 between 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, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in 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, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0185] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. 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 embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0186] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram 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 device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. 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 can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0187] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. A data encryption method, characterized in that: include: Obtaining original data and a data source identifier of the original data; According to the number of preset encryption levels, extracting target elements corresponding to the number of levels from the original data; Encrypting the data source identifier, the target element, and the original data respectively, and obtaining a first hash value, a second hash value, and a third hash value accordingly; The first hash value, the second hash value and the third hash value are placed in 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 according to claim 1, characterized in that: The step of extracting target elements of a number corresponding to the number of levels of the preset encryption levels from the original data includes: Get the preset encryption interval value; According to a preset encryption interval value, target elements of a number corresponding to the number of levels are extracted from the original data.
3. The data encryption method according to claim 2, characterized in that: The step of extracting target elements of a number corresponding to the number of levels from the original data according to the preset encryption interval value includes: Extract the initial elements of the original data; Selecting data positions whose intervals from the initial element are integer multiples of the encryption interval value, the number of the data positions being equal to the number of levels; If an element exists in the data position, extracting the element; In the case where there is no element at the data position, the number of intervals between the data position and the initial element is taken as the element corresponding to the data position, and the element is extracted.
4. The data encryption method according to claim 2, characterized in that: After obtaining the preset encryption interval value, the method further includes: Encrypting the preset encryption interval value to obtain a hash value corresponding to the preset encryption interval value; The hash value corresponding to the preset encryption interval value is added to the fourth preset position of the preset empty matrix.
5. The data encryption method according to claim 1, characterized in that: Before using the preset empty matrix as the hash value matrix corresponding to the original data, the method further includes: Encrypting the value of the preset encryption level to obtain a hash value corresponding to the preset encryption level; The hash value corresponding to the preset encryption level is added to the fifth preset position of the preset empty matrix.
6. The data encryption method according to claim 1, characterized in that: Before using the preset empty matrix as the hash value matrix corresponding to the original data, the method further includes: Acquire preset encryption sequence information, where the preset encryption sequence information indicates the arrangement sequence of the encrypted information; Encrypting the preset encryption sequence information to obtain a hash value corresponding to the preset encryption sequence information; The hash value corresponding to the preset encryption sequence information is added to the sixth preset position of the preset empty matrix.
7. The data encryption method according to any one of claims 1 to 6, characterized in that: The step of 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 includes: Placing the first hash value into the first row of a preset empty matrix; Placing the third hash value into the last row of the preset empty matrix; The third hash value is placed in a row of the preset empty matrix where no hash value is placed, to obtain a hash value matrix corresponding to the original data.
8. A data decryption method, characterized in that: include: Extracting a first hash value corresponding to the data source identifier from a first preset position of the hash value matrix; Verifying whether the first hash value matches a preset data source; In the case of matching with the preset data source, extracting the second hash value corresponding to each element from the second preset position of the hash value matrix, and extracting the third hash value corresponding to the original data from the third preset position of the hash value matrix; Verifying whether the second hash value and the third hash value match expected values; In the case of matching with the expected value, determining whether each of the elements corresponds to the original data; When each of the elements corresponds to the original data, data decryption is completed based on the original data.
9. A data encryption device, characterized in that: The device comprises: An acquisition module, used to acquire original data and a data source identifier of the original data; An extraction module, configured to extract target elements of a number corresponding to the number of levels of a preset encryption level from the original data; An encryption module, used to encrypt the data source identifier, the target element and the original data respectively, and obtain a first hash value, a second hash value and a third hash value accordingly; The inserting module is used to insert the first hash value, the second hash value and the third hash value into the first preset position, the second preset position and the third preset position of the preset empty matrix respectively, so as to obtain the hash value matrix corresponding to the original data.
10. A data encryption device, characterized in that: 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 according to any one of claims 1 to 7.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the data encryption method according to any one of claims 1 to 7 is implemented.
12. A computer program product, characterized in that When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the data encryption method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Secure data parser method and system
CN101375284A
Image encryption method and device, storage medium and electronic equipment
CN116484408A
Financial transaction data secure storage method and system based on Hash sequence
CN117057804A
Identification method and device, electronic equipment and storage medium
CN117596028A
Applying a maximum size bound on content defined segmentation of data
US20150019510A1
