An MD5-based encryption fusion storage method, device and medium

By fusing a random factor with the MD5 calculation result and embedding it into the encrypted string using a key mapping table, the problems of wasted storage space and insufficient security in MD5+SALT encrypted storage are solved, achieving seamless upgrade compatibility and improved security.

CN115577374BActive Publication Date: 2026-05-01RINGSLINK XIAMEN NETWORK COMM TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
RINGSLINK XIAMEN NETWORK COMM TECH
Filing Date
2022-10-18
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing technologies that use MD5+SALT to encrypt and store passwords require additional storage space or expansion of storage space to store random factors, resulting in wasted storage space and changes in database structure. Furthermore, they are not secure enough and are vulnerable to rainbow table attacks.

Method used

By fusing the random factor (SALT) with the MD5 calculation result, embedding the random factor into the final encrypted string using a key mapping table, and replacing it with a binary index value string, seamless storage of the random factor is achieved, avoiding additional storage space and changes to the table structure.

Benefits of technology

Saves storage space, ensures the database structure remains unchanged, improves security, prevents rainbow table credential stuffing attacks, and supports seamless compatibility between new and old solutions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115577374B_ABST
    Figure CN115577374B_ABST
Patent Text Reader

Abstract

The application provides an MD5-based encryption fusion storage method, comprising the following steps: extracting different characters according to the characteristics of the final storage value of the MD5 algorithm, mapping and encoding the extracted characters with different characters to obtain a key mapping table; obtaining a password string to be encrypted; calculating the number n of characters occupied by a random factor at most, and randomly obtaining m characters from all the characters as the random factor; performing MD5 calculation on the password string and the random factor to obtain a calculation result; performing binary conversion on each character of the random factor to obtain a binary index value of the random factor; comparing the binary index value of the random factor with the calculation result, searching the key mapping table, mapping each character of the calculation result, obtaining the fusion result of the binary index value of the random factor and the calculation result, and storing the fusion result. The application also provides an electronic device and a medium, which can save storage space, facilitate the upgrading of new and old schemes, and improve security.
Need to check novelty before this filing date? Find Prior Art

Description

An MD5-based encrypted converged storage method, device, and medium Technical Field

[0001] This invention relates to the field of information security technology, and in particular to an MD5-based encrypted fusion storage method, device, and medium. Background Technology

[0002] With the development of computer and internet technology, in this data-driven era, data breaches occur frequently. Most of these breaches are due to unencrypted data or weak encryption methods, which allow hackers to recover the original data. Therefore, data security and updates have received widespread attention.

[0003] In existing technologies, the following schemes are mostly used to encrypt data:

[0004] First, the password string is directly subjected to MD5 hashing, and the result is stored directly in a database or configuration file. With this approach, any identical input will produce the same output. If the encrypted string is leaked, malicious actors can use rainbow table attacks to crack simple plaintext passwords, resulting in insufficient security.

[0005] Secondly, to ensure security, most industry practices introduce a random factor (SALT) during MD5 calculation to increase randomness and significantly increase the difficulty of cracking. However, this approach often requires adding a new storage location for the SALT. If the entire database is leaked, malicious actors will obtain the SALT. Furthermore, adding a new storage item to the database presents challenges for upgrades and compatibility, requiring consideration of database compatibility and increasing the difficulty of modifying older solutions.

[0006] Third, some databases, for compatibility reasons, don't want to add a separate list item to store the random factor (SALT) in their tables and instead use the username as the random factor. However, this method fails to demonstrate randomness; for the same username, the encrypted string will be exactly the same, making it easy for malicious actors to deduce the random factor. Usernames, in particular, offer virtually no security.

[0007] Fourth, regarding the issues in points two and three, some solutions combine the random factor (SALT) with the final encrypted string, achieving the goal of storing two pieces of information in a single storage space. However, this still requires increasing the original storage space to accommodate the two new strings, which is not optimal for applications with limited storage. Alternatively, some designs may have a fixed storage size pre-defined, making this solution unsuitable.

[0008] Based on the above solutions, the specific problems are summarized as follows:

[0009] 1. When using MD5+SALT to encrypt and store passwords, there is a problem of needing to allocate a new storage field or expand the original storage space to store the random factor (SALT).

[0010] 2. When adding a list item to a database table to specifically store the random factor (SALT), the table structure will change, requiring a lot of work to ensure seamless compatibility between the old and new versions.

[0011] 3. Assuming the entire database is leaked, normal table names are based on their actual purpose. In the user information table, the field storing the random factor would typically be named "Salt." This makes it easy for malicious actors to obtain the random factor (SALT), allowing them to more easily perform rainbow table brute-force attacks to crack passwords, resulting in insufficient security. Summary of the Invention

[0012] To address the aforementioned issues, this invention provides an MD5-based encrypted fusion storage method. This invention integrates the random factor (SALT) selected by MD5 encryption into the final encrypted string without adding new storage space, thereby saving storage space, facilitating upgrades between old and new schemes, and improving security.

[0013] This invention is achieved through the following technical solution: This invention provides an MD5-based encrypted fusion storage method, the method comprising the following steps:

[0014] Step 1: Based on the characteristics of the final stored value of the MD5 algorithm, extract all possible different characters, and then use different characters to map and encode each extracted character to obtain a key mapping table;

[0015] Step 2: Obtain the password string to be encrypted;

[0016] Step 3: Calculate the maximum number of characters n that the random factor can occupy, where n is a positive integer; randomly select m characters from all extracted and obtained characters as random factors, where 1≤m≤n and m is a positive integer;

[0017] Step 4: Calculate the password string and random factor using the MD5 algorithm to obtain the result;

[0018] Step 5: Randomly sort all the extracted and acquired characters, and determine the binary index value corresponding to each character in the random factor based on the sorting and the total number of extracted and acquired characters, thus obtaining the binary index value string of the random factor;

[0019] Step 6: Compare the binary index string of the random factor with the calculation result, map each two binary index values ​​to one character, look up the key mapping table, replace the corresponding character in the calculation result, and obtain the fusion result of the binary index string of the random factor and the calculation result.

[0020] Step 7: Store the fusion result.

[0021] Furthermore, step 1 specifically includes:

[0022] Step 11: Based on the characteristics of the final stored value of the MD5 algorithm, extract all 16 possible different characters as the key;

[0023] Step 12: Obtain 48 different characters as the value;

[0024] Step 13: The 64 different characters are mapped and encoded using key-value distributed storage. Each key corresponds to a unique value. Each key is assigned one character, and each value is assigned three characters. Each character can only be used once.

[0025] Step 14: Each key and value is set as a group, and each group has 4 characters, where the first character is the key and the last three characters are the value; each character in each group is indexed by 2 bits, where 00 represents the first character, 01 represents the second character, 10 represents the third character, and 11 represents the fourth character, thus obtaining the key mapping table.

[0026] Furthermore, step 3 specifically includes:

[0027] Step 31: The MD5 algorithm calculates 32 characters. Assuming each character has 2 bits of binary storage space, the 32 characters correspond to a 64-bit binary storage space.

[0028] Step 32: 64 different characters require at least 6 bits of binary for indexing. The 64-bit binary merged storage space can only store a maximum of 10 characters, and the length of 10 characters requires at least 4 bits of binary to represent. Therefore, the maximum number of characters n occupied by the random factor is calculated to be 10.

[0029] Step 33: Randomly select m characters from 64 different characters as random factors, where 1≤m≤10 and m is a positive integer.

[0030] Furthermore, step 5 specifically includes:

[0031] Step 51: The 64 different characters require at least 6 bits of binary data for indexing. The 64 different characters are randomly sorted and indexed using 6 bits of binary data in order.

[0032] Step 52: Convert each character of the random factor using its corresponding 6-bit binary index value;

[0033] Step 53: If the number of characters m occupied by the random factor is in the range of 1≤m<10, then the missing part is padded with a random 6-bit binary number to obtain a complete 60-bit binary index value; if the number of characters m occupied by the random factor is 10, then no padding is required.

[0034] Step 54: Represent the number of characters m occupied by the random factor using 4 bits and place it at the end;

[0035] Step 55: Combine the complete 60-bit binary index value with the 4-bit binary value corresponding to the number of characters m occupied by the random factor to obtain the 64-bit binary index value string of the random factor.

[0036] Furthermore, step 6 specifically includes:

[0037] Step 61: Compare the 64-bit binary index value string of the random factor with the 32 characters of the calculation result, with each 2 bits of binary index value corresponding to 1 character;

[0038] Step 62: Determine whether the character corresponding to each 2-bit binary index needs to be replaced based on its position. If the 2-bit binary index is 00, it means it is located at the key position of the corresponding row, so the corresponding character remains unchanged. If the 2-bit binary index is 01, it means it is located at the value position of the corresponding row, so the corresponding character is replaced with the first character at the value position. If the 2-bit binary index is 10, it means it is located at the value position of the corresponding row, so the corresponding character is replaced with the second character at the value position. If the 2-bit binary index is 11, it means it is located at the value position of the corresponding row, so the corresponding character is replaced with the third character at the value position.

[0039] Step 63: Look up the key mapping table and replace the characters corresponding to the calculation results;

[0040] Step 64: After replacing all the characters corresponding to the calculation results, the final fusion result of the random factor binary index value string and the calculation results is obtained.

[0041] Furthermore, step 7 specifically includes:

[0042] The fusion result is stored in the original location of the database.

[0043] Furthermore, step 7 and thereafter also includes:

[0044] Step 8: Reversely parse out the random factor and the reverse mapping result. The reverse mapping result is the calculation result of the original password string and the random factor calculated by the MD5 algorithm. The password string to be verified and the random factor are calculated by the MD5 algorithm to obtain the operation result. The password string to be verified is verified by comparing the operation result with the reverse mapping result.

[0045] Furthermore, step 8 specifically includes:

[0046] Step 81: Obtain the final stored fusion result;

[0047] Step 82: Search the key mapping table to parse out all the 64-bit binary index value strings hidden in the fusion result;

[0048] Step 83: Calculate the number of characters m of the random factor based on the last 4 binary values ​​in the parsed 64-bit binary index string;

[0049] Step 84: Based on the fact that 6-bit binary index values ​​correspond to 1 character, and according to the number of characters m of the calculated random factor, parse out the m characters represented by the first 6×m binary index values ​​in the 64-bit binary index value string to obtain the final random factor;

[0050] Step 85: Find the character at the value position in the fusion result according to the key mapping table, and reverse map it back. Replace the character at the value position with the character at the key position in the same row to get the reverse mapping result.

[0051] Step 86: Perform MD5 calculation on the password string to be verified and the parsed random factor to obtain the result. Then compare the result with the reverse mapping result. If they are completely consistent, the verification is successful and the password string is correct. If they are not completely consistent, the verification fails and the password string is incorrect.

[0052] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the MD5-based encrypted fusion storage method described above.

[0053] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the MD5-based encrypted fusion storage method described above.

[0054] The beneficial effects of this invention are:

[0055] 1. This invention cleverly integrates the random factor (SALT) into the original 32-bit string in binary form, so that the original final encrypted string and the random factor (SALT) can be reverse-parsed in the 32-character storage space. This solves the problem that in the encrypted storage of MD5+SALT passwords, it is necessary to allocate a separate storage space to store the random factor (SALT), thus saving storage space.

[0056] 2. This invention does not require the addition of extra table entries or fields to store the random factor (SALT), which can ensure that the table structure of the database does not change. This eliminates the burden of compatibility when upgrading between old and new encryption schemes, and to a certain extent facilitates the seamless compatibility of the transformation between old and new schemes, making it easier to upgrade between old and new schemes.

[0057] 3. This invention also prevents criminals from obtaining the random factor (SALT) after a database leak, thus preventing them from using rainbow table brute-force attacks to crack passwords, thereby increasing security to a certain extent. Attached Figure Description

[0058] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained from these drawings without creative effort.

[0059] Figure 1 is a flowchart of a method provided by an embodiment of the present invention.

[0060] Figure 2 is a schematic diagram of an electronic device provided in an embodiment of the present invention.

[0061] Figure 3 is a schematic diagram of a computer-readable storage medium provided in an embodiment of the present invention. Detailed Implementation

[0062] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to represent selected embodiments of the invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0063] As shown in Figure 1, this embodiment of the invention provides an MD5-based encrypted fusion storage method, which includes the following steps:

[0064] Step 1: Based on the characteristics of the final stored value of the MD5 algorithm, extract all possible different characters, and then use different characters to map and encode each extracted character to obtain a key mapping table; In this invention, the SHA256 algorithm can also be used to replace the MD5 algorithm to achieve a higher level of encryption.

[0065] In this embodiment, step 1 specifically includes:

[0066] Step 11: Based on the characteristics of the final stored value of the MD5 algorithm, extract all 16 possible different characters as the key;

[0067] Step 12: Obtain 48 different characters as the value;

[0068] Step 13: The 64 different characters are mapped and encoded using key-value distributed storage. Each key corresponds to a unique value. Each key is assigned one character, and each value is assigned three characters. Each character can only be used once.

[0069] Step 14: Each key and value is grouped together, with each group consisting of 4 characters. The first character is the key, and the following three characters are the value. Each character in each group is indexed using 2 bits, where 00 represents the first character, 01 represents the second character, 10 represents the third character, and 11 represents the fourth character, thus obtaining the key mapping table. The purpose of setting the mapping encoding is to obtain the key mapping table, which facilitates searching and replacing during subsequent mapping and reverse mapping, improving the efficiency of fusion and parsing.

[0070] The MD5 algorithm generates strings that are either all uppercase or all lowercase letters. If the string is lowercase, it is encoded using the uppercase letters ABCDE; if it is uppercase, it is encoded using the lowercase letters abcde. Assume the current system always uses lowercase letters for its MD5 results.

[0071] Based on all possible values ​​calculated by the MD5 algorithm, the result can be one of 32 strings, such as "7f8e66716ea476c6ede619114a83b9e0" and "25198a579236be76263648f00c72ab12", etc., and 16 different characters are obtained as keys: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, and f.

[0072] Additionally, retrieve the 48 characters that are different from the 16 characters "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, and f": A, B, C, D, E, F, G, H, I, G, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, +, and / as values;

[0073] 64 distinct characters are mapped and encoded using a key-value distributed storage, also known as a stored KeyMap. Each key corresponds to a unique value. Each key has one character, and each value has three characters, with each character used only once. Assume the following configuration:

[0074] KeyMap: {

[0075] "0":"AQk",

[0076] "1":"BRl",

[0077] "2":"CSm",

[0078] "3":"DTn",

[0079] "4":"EUo",

[0080] "5":"FVp",

[0081] "6":"GWq",

[0082] "7":"HXr",

[0083] "8":"IYs",

[0084] "9":"JZt",

[0085] "a":"K+u",

[0086] "b":"L / v",

[0087] "c":"Mgw",

[0088] "d":"Nhx",

[0089] "e":"Oiy",

[0090] "f":"Pjz"

[0091] }

[0092] The mapping requirements are as follows: the key is one of 16 values ​​from 0 to 9a to f, and the value is one of 48 values ​​from A to Zg to z+ / . Each key corresponds to 3 values, and each value can only be used once. The order is not required.

[0093] The KeyMap above, viewed row by row, corresponds to a set of information. The first number (which is the original 0-9a-f) represents binary 00, the second represents binary 01, the third represents binary 10, and the fourth represents binary 11.

[0094] For example, in the KeyMap above, in the first row, 0 represents binary 00, A represents binary 01, Q represents binary 10, and k represents binary 11; in the fifth row, 4 represents binary 00, E represents binary 01, U represents binary 10, and o represents binary 11.

[0095] Step 2: Obtain the password string to be encrypted;

[0096] In this embodiment, it is assumed that the plaintext password string to be stored is PASSWD = "admin123";

[0097] Step 3: Calculate the maximum number of characters n that the random factor can occupy, where n is a positive integer; randomly select m characters from all extracted and obtained characters as random factors, where 1≤m≤n and m is a positive integer;

[0098] In this embodiment, step 3 specifically includes:

[0099] Step 31: The MD5 algorithm calculates 32 characters. Each character is assigned 2 bits of binary storage space, so the 32 characters correspond to 64 bits of binary storage space. Since each group of the key mapping table has 4 characters, the mapping result tells us which character in the group is mapped. No mapping is represented by 00, the first mapped character is represented by 01, the second by 10, and the third by 11. Therefore, each character can have 2 bits of binary storage space.

[0100] Step 32: The 64 different characters require at least 6 bits for indexing, such as: 000000, 000001…111110, 111111, a total of 64 possibilities. The combined storage space of 64 bits can only store a maximum of 10 characters. Then, the length of 10 characters requires at least 4 bits to represent, and 4 bits need to be reserved to represent the number of characters for the random factor, such as: 0000, 0001…1110, 1111, a total of 16 possibilities. The calculation is 6 bits * 10 characters + 4 bits = 64 bits. Therefore, the maximum number of characters n occupied by the random factor is 10.

[0101] Step 33: Randomly select m characters from 64 distinct characters as random factors, where 1 ≤ m ≤ 10 and m is a positive integer. Therefore, a maximum of 10 characters can be randomly selected from the 64 characters 0-9A-Za-z+ / as random factors. Assume the randomly selected random factor SALT = "0596aeF+". The purpose of obtaining the random factor is to combine it with the password string for calculation, thereby improving data security.

[0102] Step 4: Calculate the password string and random factor using the MD5 algorithm to obtain the result;

[0103] In this embodiment, the password string and random factor are calculated using the MD5 algorithm to obtain the value of MD5 ($PASSWD+$SALT), which is MD5(admin1230596aeF+). The calculation result is: RESULT = "7f8e66716ea476c6ede619114a83b9e0".

[0104] Step 5: Randomly sort all the extracted and acquired characters, and determine the binary index value corresponding to each character in the random factor based on the sorting and the total number of extracted and acquired characters, thus obtaining the binary index value string of the random factor;

[0105] In this embodiment, step 5 specifically includes:

[0106] Step 51: The 64 different characters require at least 6 bits for indexing. Randomly sort the 64 different characters and index them with 6 bits in order. The 64 different characters are arranged in the order 0-9A-Za-z+ / (0 to 9, 9 to A, A to Z, Z to a, a to z, z to +, + to / ). After sorting, each character is written in 6 bits, that is, 0 represents 000000, 1 represents 000001, 2 represents 000010, ... and so on, + represents 111110, / represents 111111.

[0107] Step 52: Convert each character of the random factor using its corresponding 6-bit binary index value;

[0108] The 6-bit binary representation of the random factor SALT = "0596aeF+" is as follows:

[0109] 000000(0)000101(5)001001(9)000110(6)100100(a)101000(e)001111(F)111110(+);

[0110] Step 53: If the number of characters m occupied by the random factor is in the range of 1≤m<10, then the missing part is padded with a random 6-bit binary number (e.g., 000000) to obtain a complete 60-bit binary index value; if the number of characters m occupied by the random factor is 10, then no padding is required.

[0111] The random factor SALT = "0596aeF+" has 8 characters, which is less than 10 characters. It is 2 characters short. These 2 missing characters are padded with 000000. The 6-bit binary representation of 10 characters is as follows:

[0112] 000000 000101 001001 000110 100100 101000 001111 111110 000000000000;

[0113] Step 54: Represent the number of characters m occupied by the random factor using 4 bits and place it at the end; the random factor SALT = "0596aeF+" has 8 characters, which is represented by 1000 using 4 bits.

[0114] Step 55: Combine the complete 60-bit binary index value with the 4-bit binary value corresponding to the number of characters m occupied by the random factor to obtain the 64-bit binary index value string of the random factor.

[0115] Therefore, the overall 64-bit binary index string is: 000000 000101 001001 000110 100100101000 001111 111110 000000 000000 1000.

[0116] Step 6: Compare the binary index string of the random factor with the calculation result, map each two binary index values ​​to one character, look up the key mapping table, replace the corresponding character in the calculation result, and obtain the fusion result of the binary index string of the random factor and the calculation result.

[0117] In this embodiment, step 6 specifically includes:

[0118] Step 61: Compare the 64-bit binary index value string of the random factor with the 32 characters of the calculation result, with each 2 bits of binary index value corresponding to 1 character;

[0119] like:

[0120]

[0121] Step 62: Determine whether the character corresponding to each 2-bit binary index needs to be replaced based on its position. If the 2-bit binary index is 00, it means it is located at the key position of the corresponding row, so the corresponding character remains unchanged. If the 2-bit binary index is 01, it means it is located at the value position of the corresponding row, so the corresponding character is replaced with the first character at the value position. If the 2-bit binary index is 10, it means it is located at the value position of the corresponding row, so the corresponding character is replaced with the second character at the value position. If the 2-bit binary index is 11, it means it is located at the value position of the corresponding row, so the corresponding character is replaced with the third character at the value position.

[0122] Step 63: Look up the key mapping table and replace the characters corresponding to the calculation results;

[0123] "0":"AQk","1":"BRl","2":"CSm","3":"DTn",

[0124] "4":"EUo","5":"FVp","6":"GWq","7":"HXr",

[0125] "8":"IYs","9":"JZt","a":"K+u","b":"L / v",

[0126] "c":"Mgw","d":"Nhx","e":"Oiy","f":"Pjz"

[0127] For example: the KeyMap corresponding to the first character 7 in the calculation result is HXr, and the 2-bit binary index value of 7 is 00, so this character is still replaced with 7;

[0128] The KeyMap corresponding to the second character f in the calculation result is Pjz, and the 2-bit binary index value of f is 00, so this character is still replaced with f;

[0129] The KeyMap corresponding to the third character 8 in the calculation result is IYs, and the 2-bit binary index value corresponding to 8 is 00, so this character is still replaced with 8;

[0130] The KeyMap corresponding to the fourth character 'e' in the calculation result is Oiy, and the 2-bit binary index value of 'e' is 00, so this character is still replaced with 'e'.

[0131] The KeyMap corresponding to the 5th character 6 in the calculation result is GWq. Then, the 2-bit binary index value of 6 is 01, so this character mapping is replaced with the character G at the binary index value 01.

[0132] Similarly, the 32nd character of the calculation result is mapped and replaced.

[0133] Step 64: After replacing all the characters corresponding to the calculation result, the final fusion result of the random factor binary index value string and the calculation result is obtained; the final string is as follows:

[0134] 7f8eGG7RGeKUXGcWideqltlR4a83b9i0.

[0135] Step 7: Store the fusion result.

[0136] In this embodiment, step 7 specifically includes:

[0137] The fusion result: 7f8eGG7RGeKUXGcWideqltlR4a83b9i0 is stored in the original location of the database;

[0138] The present invention has the following advantages:

[0139] 1. This invention cleverly integrates the random factor (SALT) into the original 32-bit string in binary form, so that the original final encrypted string and the random factor (SALT) can be reverse-parsed in the 32-character storage space. This solves the problem that in the encrypted storage of MD5+SALT passwords, it is necessary to allocate a separate storage space to store the random factor (SALT), thus saving storage space.

[0140] 2. This invention does not require the addition of extra table entries or fields to store the random factor (SALT), which can ensure that the table structure of the database does not change. This eliminates the burden of compatibility when upgrading between old and new encryption schemes, and to a certain extent facilitates the seamless compatibility of the transformation between old and new schemes, making it easier to upgrade between old and new schemes.

[0141] 3. This invention also prevents criminals from obtaining the random factor (SALT) after a database leak, thus preventing them from using rainbow table brute-force attacks to crack passwords, thereby increasing security to a certain extent.

[0142] Step 8: Reversely parse out the random factor SALT and the reverse mapping result RESULT. The reverse mapping result is the result of the original password string and the random factor calculated by the MD5 algorithm. The password string to be verified and the random factor are then calculated by the MD5 algorithm to obtain the operation result. The password string to be verified is verified by comparing the operation result with the reverse mapping result.

[0143] In this embodiment, step 8 specifically includes:

[0144] Step 81: Obtain the final stored fusion result, that is, the final stored string is "7f8eGG7RGeKUXGcWideqltlR4a83b9i0";

[0145] Step 82: Look up the key mapping table to merge the results:

[0146] The hidden 64-bit binary index string “7f8eGG7RGeKUXGcWideqltlR4a83b9i0” is fully parsed as follows:

[0147] 000000000101001001000110100100101000001111111110000000000001000;

[0148] Step 83: Calculate the number of random factor characters m based on the last 4 binary values ​​in the parsed 64-bit binary index string; that is, the number of random factor strings whose last 4 binary (1000) values ​​are 8.

[0149] Step 84: Based on the fact that 6 binary index values ​​correspond to 1 character, and according to the number of characters m of the calculated random factor, parse out the m characters represented by the first 6×m binary index values ​​in the 64-bit binary index string. That is, parse out the 8 characters represented by the first 48 binary index values ​​in the 64-bit binary index string as "0596aeF+", and obtain the final random factor "0596aeF+".

[0150] Step 85: Find the fusion result based on the key mapping table:

[0151] The character at the value position (not 0-9a-f) in “7f8eGG7RGeKUXGcWideqltlR4a83b9i0” is then mapped back, and the character at the value position is replaced with the character at the corresponding key position in the same line. The result of the reverse mapping is:

[0152] Therefore, the actual password string and the random factor SALT are calculated using the MD5 algorithm to obtain the result: RESULT = "7f8e66716ea476c6ede619114a83b9e0".

[0153] Step 86: Perform MD5 calculation on the password string to be verified, $CHECKPWD, and the parsed random factor SALT to obtain the operation result CHECKRUSULT = MD5($CHECKPWD + $SALT). Then compare the operation result $CHECKRUSULT with the obtained reverse mapping result $RESULT. If they are completely consistent, it means that the verification is successful and the password string is correct. If they are not completely consistent, it means that the verification fails and the password string is wrong.

[0154] As long as the original string and the KeyMap can be reversibly converted, other information can be integrated and stored in other fields to save space, not just for password verification. This approach is highly valuable for embedded devices with limited storage space.

[0155] As shown in Figure 2, this embodiment of the invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the above-described MD5-based encrypted fusion storage method.

[0156] As shown in Figure 3, this embodiment of the invention also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, it implements the above-described MD5-based encrypted fusion storage method.

[0157] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the invention by those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the invention should be included within the scope of protection of the invention.

Claims

1. A method for encrypted fusion storage based on MD5, characterized in that, The method includes the following steps: Step 1: Based on the characteristics of the final stored value of the MD5 algorithm, extract all possible different characters, and further obtain different characters to map and encode each extracted character to obtain a key mapping table; Step 2: Obtain the password string to be encrypted; Step 3: Calculate the maximum number of characters n occupied by the random factor, where n is a positive integer; randomly select m characters from all extracted and obtained characters as random factors, where 1≤m≤n and m is a positive integer; Step 4: Calculate the password string and random factors using the MD5 algorithm to obtain the calculation result; Step 5: Randomly sort all extracted and obtained characters, and determine the binary index value corresponding to each character in the random factor based on the sorting and the total number of extracted and obtained characters to obtain the binary index value string of the random factor; Step 6: Compare the binary index value string of the random factor with the calculation result, map each two binary index values ​​to one character, search the key mapping table, replace the character corresponding to the calculation result, and obtain the fusion result of the binary index value string of the random factor and the calculation result; Step 7: Store the fusion result.

2. The MD5-based encrypted fusion storage method according to claim 1, characterized in that, Step 1 specifically includes: Step 11, based on the characteristics of the final stored value of the MD5 algorithm, extract all 16 possible different characters as keys; Step 12, obtain another 48 different characters as values; Step 13, map and encode the 64 different characters using key-value distributed storage, with each key corresponding to a unique value, each key having one character, and each value having three characters, and each character can only be used once; Step 14, set each key and value as a group, with each group having 4 characters, where the first character is the key and the last three characters are the value; each character in each group is indexed with 2 bits of binary, where 00 represents the first character, 01 represents the second character, 10 represents the third character, and 11 represents the fourth character, thus obtaining the key mapping table.

3. The MD5-based encrypted fusion storage method according to claim 2, characterized in that, Step 3 specifically includes: Step 31, the MD5 algorithm calculates 32 characters, and each character is set to have a 2-bit binary fusion storage space, so the 32 characters correspond to a 64-bit binary fusion storage space; Step 32, the 64 different characters use at least 6 bits of binary for indexing, the 64-bit binary fusion storage space can only store a maximum of 10 characters, and the length of 10 characters requires at least 4 bits of binary to represent, so the maximum number of characters n occupied by the random factor is calculated to be 10; Step 33, randomly select m characters from the 64 different characters as random factors, 1≤m≤10 and m is a positive integer.

4. The MD5-based encrypted fusion storage method according to claim 3, characterized in that, Step 5 specifically includes: Step 51, 64 different characters are indexed using at least 6 bits of binary data. The 64 different characters are randomly sorted and indexed using 6 bits of binary data in order; Step 52, each character of the random factor is converted using its corresponding 6-bit binary index value; Step 53, if the number of characters m occupied by the random factor is in the range of 1 ≤ m < 10, the missing part is padded with a random 6-bit binary data to obtain a complete 60-bit binary index value; if the number of characters m occupied by the random factor is 10, no padding is required; Step 54, the number of characters m occupied by the random factor is represented by 4 bits of binary data and placed at the end; Step 55, the complete 60-bit binary index value and the 4-bit binary data corresponding to the number of characters m occupied by the random factor are combined to obtain a 64-bit binary index value string of the random factor.

5. The MD5-based encrypted fusion storage method according to claim 4, characterized in that, Step 6 specifically includes: Step 61, comparing the 64-bit binary index string of the random factor with the 32 characters of the calculation result, with each 2-bit binary index value corresponding to one character; Step 62, determining whether the character corresponding to each 2-bit binary index value needs to be replaced based on its position. If the 2-bit binary index value is 00, it means it is located at the key position in the corresponding row, so the corresponding character remains unchanged; if the 2-bit binary index value is 01, it means it is located at the value position in the corresponding row, so the corresponding character is replaced with the first character at the value position; if the 2-bit binary index value is 10, it means it is located at the value position in the corresponding row, so the corresponding character is replaced with the second character at the value position; if the 2-bit binary index value is 11, it means it is located at the value position in the corresponding row, so the corresponding character is replaced with the third character at the value position; Step 63, searching the key mapping table and replacing the characters corresponding to the calculation result; Step 64, after replacing all the characters corresponding to the calculation result, the final fusion result of the random factor binary index string and the calculation result is obtained.

6. The MD5-based encrypted fusion storage method according to claim 1, characterized in that, Step 7 specifically includes: storing the fusion result in the original location of the database.

7. The MD5-based encrypted fusion storage method according to claim 2, characterized in that, Step 7 and beyond also includes: Step 8, reversing the parsing of the random factor and the reverse mapping result. The reverse mapping result is the calculation result of the original password string and the random factor calculated by the MD5 algorithm. The password string to be verified and the random factor are calculated by the MD5 algorithm to obtain the operation result. The password string to be verified is verified by comparing the operation result with the reverse mapping result.

8. The MD5-based encrypted fusion storage method according to claim 7, characterized in that, Step 8 specifically includes: Step 81, obtaining the final stored fusion result; Step 82, searching the key mapping table to parse out all the hidden 64-bit binary index value strings in the fusion result; Step 83, calculating the number of characters m of the random factor based on the last 4 binary values ​​in the parsed 64-bit binary index value string; Step 84, according to the principle that 6 binary index values ​​correspond to 1 character, parsing out the m characters represented by the first 6×m binary index values ​​in the 64-bit binary index value string based on the calculated number of characters m of the random factor, to obtain the final random factor; Step 85, searching for the character at the value position in the fusion result according to the key mapping table, and reversing the mapping back, replacing the character at the value position with the character at the key position corresponding to the same row, to obtain the reverse mapping result; Step 86, performing MD5 calculation on the password string to be verified and the parsed random factor to obtain the operation result, and then comparing the operation result with the obtained reverse mapping result. If they are completely consistent, it means that the verification is successful and the password string is correct; if they are not completely consistent, it means that the verification fails and the password string is incorrect.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements an MD5-based encrypted fusion storage method as described in any one of claims 1 to 8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements an MD5-based encrypted fusion storage method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Password verification method and system for preventing library collision attack, middleware and storage medium

    CN110445618A

  • Hierarchical mapping-based automatic balancing storage method for ceph storage system

    WO2022028033A1