CN115577374A - Encryption fusion storage method, device and medium based on MD5 - Google Patents

Encryption fusion storage method, device and medium based on MD5 Download PDF

Info

Publication number
CN115577374A
CN115577374A CN202211273932.4A CN202211273932A CN115577374A CN 115577374 A CN115577374 A CN 115577374A CN 202211273932 A CN202211273932 A CN 202211273932A CN 115577374 A CN115577374 A CN 115577374A
Authority
CN
China
Prior art keywords
character
characters
bit binary
random factor
index value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211273932.4A
Other languages
Chinese (zh)
Inventor
钟兴顺
陈少伟
陈毅聪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ringslink Xiamen Network Communication Technologies Co ltd
Original Assignee
Ringslink Xiamen Network Communication Technologies Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ringslink Xiamen Network Communication Technologies Co ltd filed Critical Ringslink Xiamen Network Communication Technologies Co ltd
Priority to CN202211273932.4A priority Critical patent/CN115577374A/en
Publication of CN115577374A publication Critical patent/CN115577374A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/126Character encoding

Abstract

The invention provides an encryption fusion storage method based on MD5, which comprises the following steps: extracting different characters according to the characteristics of the final storage value of the MD5 algorithm, and mapping and coding the extracted characters by additionally taking different characters to obtain a key mapping table; acquiring a password string to be encrypted; calculating the number n of characters occupied by the random factor at most, and randomly acquiring 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 random factor with the calculation result, searching a key mapping table, mapping each character of the calculation result to obtain a fusion result of the binary index value of the random factor and the calculation result; and storing the fusion result. The invention also provides electronic equipment and a medium, which can save storage space, facilitate the upgrading of new and old schemes and improve safety.

Description

Encryption fusion storage method, device and medium based on MD5
Technical Field
The invention relates to the technical field of information security, in particular to an encryption fusion storage method, equipment and a medium based on MD 5.
Background
With the development of computer and internet technologies, data leakage occurs in the data era, and most of the data is not encrypted or the encryption mode is weak, so that hackers can restore original data, and therefore security and updating of the data are widely concerned.
In the prior art, the following schemes are mostly adopted to encrypt data:
first, the cipher string is directly subjected to MD5 calculation, and then the result of MD5 calculation is directly stored in a database or a configuration file. According to the scheme, any same input has the same output, and if the encryption string is leaked out, lawless persons can crack simple plaintext passwords of some users through a rainbow table collision library, so that the safety is insufficient.
Secondly, in order to ensure security, most of the industry introduces a random factor (SALT) to perform MD5 calculation to increase randomness, so that the cracking difficulty is greatly increased. However, for this scheme, many places to store the random factor (SALT) must be added. If the entire database is revealed, the lawbreaker can take the random factor. And the newly added storage items of the database are still troublesome for some upgrading compatibility, and the compatible objects of the database need to be considered, so that the difficulty of modifying the old scheme is increased.
Thirdly, some of them do not want to add a new list item in the table of the database to specially store the random factor (SALT) because of the compatibility problem, and the user name will be used as the random factor. However, the randomness of the usage is not reflected, and the final result of the encrypted character strings of the same user name is the same, so that the user name is easy to collide by lawbreakers, and the user name basically has no confidentiality.
Fourth, some of the second and third problems may be to put a random factor (SALT) together with the final encryption string, so that only one storage space can store two pieces of information. In order to solve this problem, the original storage space needs to be increased to store the new two character strings, and for some storage spaces are tight, the storage space is not optimal. Or some designs may have written down a fixed amount of memory space before the beginning, and cannot be handled with this scheme.
By combining the above schemes, the problems are summarized as follows:
1. in the process of encrypting and storing the password by using MD5+ SALT, a new storage field needs to be opened up additionally or the original storage space needs to be enlarged to store a random factor (SALT);
2. when a list item is newly added in a table of a database to specially store a random factor (SALT), the table structure is changed, and more work is required to be done to ensure seamless compatibility of new and old versions when the table is updated and compatible;
3. assuming that the entire database is exposed, the normal table structure naming is based on the actual usage. Then, in the data table of the user information, the field for storing the random factor is normally named as Salt, so that a lawbreaker can easily obtain the random factor (SALT), and therefore, rainbow table collision library blasting can be performed more easily to break the password, and the safety is insufficient.
Disclosure of Invention
In order to solve the problems, the invention provides an encryption fusion storage method based on MD5, which perfectly fuses random factors (SALT) selected by MD5 encryption into a final encryption string under the condition of not increasing a storage space, can save the storage space, is convenient for upgrading old and new schemes and improves the safety.
The invention is realized by the following technical scheme: the invention provides an encryption fusion storage method based on MD5, which comprises the following steps:
step 1, extracting all possible different characters according to the characteristic of a final storage value of an MD5 algorithm, and acquiring different characters to perform mapping coding on each extracted character to obtain a key mapping table;
step 2, obtaining a password string to be encrypted;
step 3, calculating the number n of the characters occupied by the random factors at most, wherein n is a positive integer; randomly acquiring m characters from all extracted and acquired characters as random factors, wherein m is more than or equal to 1 and less than or equal to n, and m is a positive integer;
step 4, calculating the password string and the random factor through an MD5 algorithm to obtain a calculation result;
step 5, randomly sequencing all extracted and obtained characters, and determining a binary index value corresponding to each character in the random factor according to the sequencing, the total number of all extracted and obtained characters to obtain a binary index value string of the random factor;
step 6, comparing the binary index value string of the random factor with the calculation result, mapping according to that each two binary index values correspond to one character, searching a key mapping table, replacing the character corresponding to the calculation result, and obtaining a fusion result of the binary index value string of the random factor and the calculation result;
and 7, storing the fusion result.
Further, the step 1 specifically includes:
step 11, extracting all possible 16 different characters as keys according to the characteristic of the final storage value of the MD5 algorithm;
step 12, acquiring 48 different characters as values;
step 13, mapping and coding 64 different characters in key-value distributed storage, wherein each key corresponds to a unique value, each key is provided with one character, each value is provided with three characters, and each character can only be used once;
step 14, setting each key and one value as a group, wherein each group is provided with 4 characters, the first character is the key, and the last three characters are the values; each character of each group is indexed by 2-bit binary, wherein 00 represents a first character, 01 represents a second character, 10 represents a third character, and 11 represents a fourth character, so as to obtain a key mapping table.
Further, the step 3 specifically includes:
step 31, calculating results by an MD5 algorithm to be 32 characters, setting each character to have a 2-bit binary fusion storage space, and enabling the 32 characters to correspond to a 64-bit binary fusion storage space;
step 32, indexing 64 different characters by using a 6-bit binary system at least, wherein the fusion storage space of the 64-bit binary system can only store 10 characters at most, the length of the 10 characters is minimum and needs the 4-bit binary system to represent, and the number n of the characters occupied by the random factor at most is calculated to be 10;
and step 33, randomly acquiring m characters from 64 different characters as random factors, wherein m is more than or equal to 1 and less than or equal to 10, and m is a positive integer.
Further, the step 5 specifically includes:
step 51, indexing 64 different characters by using a 6-bit binary system at least, randomly sequencing the 64 different characters, and respectively indexing the 64 different characters by using the 6-bit binary system according to the sequence;
step 52, converting each character of the random factor by using a corresponding 6-bit binary index value;
step 53, if the number m of the characters occupied by the random factor is within the range that m is more than or equal to 1 and less than 10, the missing part is complemented in the back by using a random 6-bit binary system to obtain a complete 60-bit binary index value; if the number m =10 of the characters occupied by the random factor, the completion is not needed;
step 54, expressing the number m of the characters occupied by the random factor by using a 4-bit binary system, and placing the number m at the last position;
and step 55, combining the complete 60-bit binary index value with the 4-bit binary corresponding to the character number m occupied by the random factor to obtain a 64-bit binary index value string of the random factor.
Further, the step 6 specifically includes:
step 61, comparing the 64-bit binary index value string of the random factor with 32 characters of the calculation result, wherein each 2-bit binary index value corresponds to 1 character;
step 62, judging whether 1 character corresponding to the 2-bit binary index value needs to be replaced according to the position corresponding to each 2-bit binary index value, if the 2-bit binary index value is 00, indicating that the character is located at the key position of the row corresponding to the character, and keeping the corresponding character unchanged; if the 2-bit binary index value is 01, indicating that the character is located at the value position of the corresponding line of the character, replacing the corresponding character with the first character at the value position; if the 2-bit binary index value is 10, indicating that the character is located at the value position of the corresponding line of the character, replacing the corresponding character with a second character at the value position; if the 2-bit binary index value is 11, indicating that the character is located at the value position of the corresponding line of the character, replacing the corresponding character with a third character at the value position;
step 63, searching a key mapping table, and replacing characters corresponding to the calculation result;
and step 64, after all characters corresponding to the calculation result are replaced, obtaining a final fusion result of the random factor binary index value string and the calculation result.
Further, the step 7 specifically includes:
and storing the fusion result in the original position of the database.
Further, step 7 is followed by:
and 8, reversely analyzing a random factor and a reverse mapping result, wherein the reverse mapping result is a calculation result of the original password string and the random factor calculated by the MD5 algorithm, calculating the password string to be verified and the random factor by the MD5 algorithm to obtain an operation result, and verifying the password string to be verified according to the comparison operation result and the reverse mapping result.
Further, the step 8 specifically includes:
step 81, obtaining a final stored fusion result;
step 82, searching the key mapping table to completely analyze the 64-bit binary index value string hidden in the fusion result;
step 83, calculating the character number m of the random factor according to the last 4-bit binary number value in the analyzed 64-bit binary index value string;
step 84, resolving m characters represented by the previous 6 x m-bit binary index value in the 64-bit binary index value string according to the calculated character number m of the random factor and corresponding to 1 character according to the 6-bit binary index value to obtain a final random factor;
step 85, searching the character at the value position in the fusion result according to the key mapping table, reversely mapping the character at the value position to the character at the key position corresponding to the row of the character, and obtaining a reverse mapping result;
and 86, performing MD5 calculation on the password string to be verified and the analyzed random factor to obtain an operation result, then comparing the operation result with the obtained reverse mapping result, if the operation result is completely consistent with the obtained reverse mapping result, indicating that the verification is successful, the password string is right, and if the operation result is not completely consistent with the obtained reverse mapping result, indicating that the verification is failed, and the password string is wrong.
The invention also provides an electronic device, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor executes the computer program to realize the MD 5-based encryption fusion storage method.
The present invention also provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements an MD 5-based encryption fusion storage method as described above.
The invention has the beneficial effects that:
1. the invention skillfully fuses the random factor (SALT) into the original 32-bit character string in a binary mode, achieves the purpose of reversely analyzing the original final encrypted character string and the random factor (SALT) in a 32-character storage space, solves the problem that a section of storage space is additionally required to be opened for storing the random factor (SALT) in the encrypted storage of the password using MD5+ SALT, and saves the storage space;
2. the invention does not need to add additional table items or fields to store random factors (SALT), can ensure that the table structure of the database does not change, thus when upgrading the new and old encryption schemes, the invention does not need to be compatible with the load of the heart, thereby being convenient for the seamless compatibility problem of the transformation of the new and old schemes to a certain extent and being convenient for the upgrading of the new and old schemes;
3. the invention can also make lawless persons not to get random factor (SALT) after the database is leaked, thereby not being able to carry out rainbow table collision library blasting to break the password and also increasing the safety to a certain extent.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a flowchart of a method provided by an embodiment of the present invention.
Fig. 2 is a schematic diagram of an electronic device according to an embodiment of the present invention.
Fig. 3 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
As shown in fig. 1, an embodiment of the present invention provides an MD 5-based encryption fusion storage method, where the method includes the following steps:
step 1, extracting all possible different characters according to the characteristic of a final storage value of an MD5 algorithm, and acquiring different characters to perform mapping coding on each extracted character to obtain a key mapping table; in the invention, the MD5 algorithm can be replaced by the sha256 algorithm, so that higher-level encryption degree can be achieved.
In this embodiment, the step 1 specifically includes:
step 11, extracting all possible 16 different characters as keys according to the characteristic of the final storage value of the MD5 algorithm;
step 12, acquiring 48 different characters as values;
step 13, mapping and coding 64 different characters in key-value distributed storage, wherein each key corresponds to a unique value, each key is provided with one character, each value is provided with three characters, and each character can only be used once;
step 14, setting each key and one value as a group, wherein each group is provided with 4 characters, the first character is the key, and the last three characters are the values; each character of each group is indexed by 2-bit binary, wherein 00 represents a first character, 01 represents a second character, 10 represents a third character, and 11 represents a fourth character, so as to obtain a key mapping table. The purpose of setting mapping codes is to obtain a key mapping table, so that the key mapping table can be conveniently searched and replaced when mapping and reverse mapping are carried out later, and the efficiency of fusion and analysis is improved.
The characters calculated by the MD5 algorithm are all capital letters or all lowercase letters related to letters, if the characters calculated by the MD5 algorithm are lowercase letters, the characters are coded by ABCDE of the capital letters, and if the characters calculated by the MD5 algorithm are uppercase letters, the characters are coded by ABCDE of the lowercase letters. Assume that the MD5 calculations for the current system are all in lower case.
All possible result values calculated according to the MD5 algorithm are 32 character strings, such as: "7f8e66716ea476c6ede619114a83b9e0", "25198a579236be76263648f00c72ab12", etc., obtaining 16 different characters: 0. 1,2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e and f as keys;
in addition, 48 characters different from the 16 characters "0, 1,2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, and f" are acquired: 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/or as value;
64 different characters are mapped and encoded in key-value distributed storage, which can also be called as stored KeyMap, each key corresponds to a unique value, each key is provided with one character, each value is provided with three characters, and each character can only be used once; assume that the settings are as follows:
KeyMap:{
"0":"AQk",
"1":"BRl",
"2":"CSm",
"3":"DTn",
"4":"EUo",
"5":"FVp",
"6":"GWq",
"7":"HXr",
"8":"IYs",
"9":"JZt",
"a":"K+u",
"b":"L/v",
"c":"Mgw",
"d":"Nhx",
"e":"Oiy",
"f":"Pjz"
}
the mapping requirements are as follows: the keys are 16 values of 0-9a-f, the value is A-Zg-z +/48, each key corresponds to 3 values, each value can be used only once, and the sequence is not required.
The KeyMap above, viewed per row, corresponds to a set of information, the first digit (i.e., the original 0-9 a-f) representing a binary 00, the second representing a binary 01, the third representing a binary 10, and the fourth representing a binary 11.
For example, in the above KeyMap, the first line, 0 represents binary 00, a represents binary 01, q represents binary 10, k represents binary 11; in the fifth row, 4 represents binary 00, E represents binary 01, U represents binary 10, o represents binary 11.
Step 2, obtaining a password string to be encrypted;
in this embodiment, it is assumed that the cipher string plaintext paswd = "admin123" needs to be stored;
step 3, calculating the number n of the characters occupied by the random factors at most, wherein n is a positive integer; randomly acquiring m characters from all extracted and acquired characters as random factors, wherein m is more than or equal to 1 and less than or equal to n, and m is a positive integer;
in this embodiment, the step 3 specifically includes:
step 31, the result calculated by the MD5 algorithm is 32 characters, each character is set to have a 2-bit binary fusion storage space, and then the 32 characters correspond to the fusion storage space with a 64-bit binary fusion storage space; since each group of the key mapping table is 4 characters, it can be known from the mapping result that the second of the group is mapped, no 00 is mapped, the first representation of the mapping is 01, the second representation is mapped 10, and the third representation is mapped 11, so each character can have a binary fused memory space of 2 bits.
Step 32, indexing 64 different characters by using 6-bit binary system at least, such as: 5363 and 000000,000001 … 111110,111111, 64 kinds of binary system with 64 bits can store only 10 characters at most. Then, the length of 10 characters needs 4-bit binary system to represent at least, and 4-bit binary system is left to represent the number of characters of random factors, such as: 0000,0001 … 1110,1111, 16 kinds in total, 6 bits × 10 characters +4 bits =64 bits are calculated, and the number n of the characters occupied by the random factor at most is calculated to be 10;
step 33, randomly acquiring m characters from 64 different characters as random factors, wherein m is more than or equal to 1 and less than or equal to 10, and m is a positive integer; so from 0-9A-Za-z +/these 64 characters up to 10 characters are supported randomly as random factors, assume random factor SALT = "0596aeF +". The purpose of obtaining the random factor is to perform combined calculation with the password string, so that the data security is improved.
Step 4, calculating the password string and the random factor through an MD5 algorithm to obtain a calculation result;
in this embodiment, the code string and the random factor are calculated by the MD5 algorithm, so as to calculate the value of MD5 ($ PASSWD + $ SALT), that is, MD5 (admin 1230596aeF +), and the calculation result is: RESULT = "7f8e66716ea476c6ede619114a83b9e0";
step 5, randomly sequencing all extracted and obtained characters, and determining a binary index value corresponding to each character in the random factor according to the sequencing, the total number of all extracted and obtained characters to obtain a binary index value string of the random factor;
in this embodiment, the step 5 specifically includes:
step 51, indexing 64 different characters by using a 6-bit binary system at least, randomly sequencing the 64 different characters, and indexing the 64 different characters by using the 6-bit binary system according to the sequence; 64 different characters are arranged in the order of 0-9A-Za-Z +/(0 to 9,9 to A, A to Z, Z to a, a to Z, Z to +, + to /) and after sorting each character is written in 6-bit binary, i.e. 0 denotes 000000,1, 000001,2, 000010, …, and so on, + denotes 111110,/denotes 111111;
step 52, converting each character of the random factor by using a corresponding 6-bit binary index value;
the 6-bit binary representation of the random factor SALT = "0596aeF +" is as follows:
000000(0)000101(5)001001(9)000110(6)100100(a)101000(e)001111(F)111110(+);
step 53, if the number m of the characters occupied by the random factor is within the range that m is more than or equal to 1 and less than 10, the missing part is complemented in the following by using a random 6-bit binary system (such as 000000) to obtain a complete 60-bit binary index value; if the number m =10 of the characters occupied by the random factor, the completion is not needed;
the random factor SALT = "0596aeF +" has 8 characters, no 10 characters are full, 2 characters are different, the two missing characters are filled up with 000000, and the 6-bit binary of 10 characters is represented as follows:
000000 000101 001001 000110 100100 101000 001111 111110 000000 000000;
step 54, expressing the number m of the characters occupied by the random factor by using a 4-bit binary system, and placing the number m at the last position; the number of characters of the random factor SALT = '0596 aeF +' is 8, and the number is 1000 by using 4-bit binary representation;
and step 55, combining the complete 60-bit binary index value with the 4-bit binary corresponding to the character number m occupied by the random factor to obtain a 64-bit binary index value string of the random factor.
So the overall 64-bit binary index value string is: 000000 000101 001001 000110 100100 101000 001111 111110 000000 000000 1000.
Step 6, comparing the binary index value string of the random factor with the calculation result, mapping according to that each two binary index values correspond to one character, searching a key mapping table, replacing the character corresponding to the calculation result, and obtaining a fusion result of the binary index value string of the random factor and the calculation result;
in this embodiment, the step 6 specifically includes:
step 61, comparing the 64-bit binary index value string of the random factor with 32 characters of the calculation result, wherein each 2-bit binary index value corresponds to 1 character;
such as:
Figure BDA0003896286930000131
step 62, judging whether 1 character corresponding to the 2-bit binary index value needs to be replaced according to the position corresponding to each 2-bit binary index value, if the 2-bit binary index value is 00, indicating that the character is located at the key position of the row corresponding to the character, and keeping the corresponding character unchanged; if the 2-bit binary index value is 01, indicating that the character is located at the value position of the corresponding line of the character, replacing the corresponding character with the first character at the value position; if the 2-bit binary index value is 10, indicating that the character is located at the value position of the corresponding line of the character, replacing the corresponding character with a second character at the value position; if the 2-bit binary index value is 11, indicating that the character is located at the value position of the corresponding line of the character, replacing the corresponding character with a third character at the value position;
step 63, searching a key mapping table, and replacing characters corresponding to the calculation result;
"0":"AQk","1":"BRl","2":"CSm","3":"DTn",
"4":"EUo","5":"FVp","6":"GWq","7":"HXr",
"8":"IYs","9":"JZt","a":"K+u","b":"L/v",
"c":"Mgw","d":"Nhx","e":"Oiy","f":"Pjz"
such as: the KeyMap corresponding to the 1 st character 7 of the calculation result is mapped to HXr, and then the 2-bit binary index value corresponding to 7 is 00, so that the character is still replaced by 7;
the KeyMap corresponding to the 2 nd character f of the calculation result is mapped into Pjz, and then the 2-bit binary index value corresponding to f is 00, so that the character is still replaced by f;
the KeyMap corresponding to the 3 rd character 8 of the calculation result is mapped to IYs, and then the 2-bit binary index value corresponding to 8 is 00, so that the character is still replaced by 8;
the KeyMap corresponding to the 4 th character e of the calculation result is mapped to Oiy, and then the 2-bit binary index value corresponding to e is 00, so that the character is replaced by e;
the KeyMap corresponding to the 5 th character 6 of the calculation result is mapped to GWq, and then the 2-bit binary index value corresponding to 6 is 01, so that the character mapping is replaced by the character G at the position of the binary index value 01;
and by analogy, mapping replacement is carried out on all the 32 th characters of the calculation result.
Step 64, after all characters corresponding to the calculation result are replaced, obtaining a final fusion result of the random factor binary index value string and the calculation result; the final string is as follows:
7f8eGG7RGeKUXGcWideqltlR4a83b9i0。
and 7, storing the fusion result.
In this embodiment, the step 7 specifically includes:
and (3) the fusion result is: 7f8eGG7RGeKUXGcWideqltlR4a83b9i0 is stored in the original location of the database;
the invention has the following advantages:
1. the invention skillfully fuses the random factor (SALT) into the original 32-bit character string in a binary mode, achieves the purpose that the original final encrypted character string and the random factor (SALT) can be reversely analyzed in a 32-character storage space, solves the problem that a section of storage space is additionally opened for storing the random factor (SALT) in the encryption storage of the MD5+ SALT password, and saves the storage space;
2. the invention does not need to add additional table entries or fields to store random factors (SALT), can ensure that the table structure of the database does not change, thus, when the new and old encryption schemes are upgraded, the invention does not need to have the cardiac burden of compatibility, is convenient for the seamless compatibility problem of the transformation of some new and old schemes to a certain extent, and is convenient for the upgrading of the new and old schemes;
3. the invention can also make lawless persons not to get random factor (SALT) after the database is leaked, thereby not being able to carry out rainbow table collision library blasting to break the password and also increasing the safety to a certain extent.
And 8, reversely analyzing a random factor SALT and a reverse mapping RESULT RESULT, wherein the reverse mapping RESULT is a calculation RESULT of the original password string and the random factor calculated by the MD5 algorithm, calculating the password string to be verified and the random factor by the MD5 algorithm to obtain an operation RESULT, and verifying the password string to be verified according to the comparison operation RESULT and the reverse mapping RESULT.
In this embodiment, the step 8 specifically includes:
step 81, obtaining the finally stored fusion result, that is, the finally stored character string is "7f8eGG7RGeKUXGcWideqltlR4a83b9i0";
step 82, searching a key mapping table to fuse the results:
the hidden 64-bit binary index value string of "7f8eGG rgekuxgwideqltlr 4a83b9i0" is parsed into:
0000000001010010010001101001001010000011111111100000000000001000;
step 83, calculating the character number m of the random factor according to the last 4-bit binary number value in the analyzed 64-bit binary index value string; namely, the number of the character strings of the random factor is 8 in the last 4-bit binary system (1000);
step 84, according to the 1 character corresponding to the 6-bit binary index value, resolving m characters represented by the previous 6 × m-bit binary index value in the 64-bit binary index value string according to the calculated character number m of the random factor, that is, resolving 8 characters represented by the previous 48-bit binary index value in the 64-bit binary index value string as: "0596aeF +" to obtain the final random factor "0596aeF +";
step 85, searching the fusion result according to the key mapping table:
the characters at the value position (not 0-9 a-f) in the 7f8eGG RGeKUXGCWideqltlR4a83b9i0 are reversely mapped, the characters at the value position are replaced by the characters at the key position corresponding to the row, and the reverse mapping result is obtained as follows:
"7f8e66716ea476c6ede619114a83b9e0", so the calculation RESULT of true code string and random factor SALT by MD5 algorithm is RESULT = "7f8e66716ea476c6ede619114a83b9e0";
step 86, MD5 calculation is performed on the password string $ checkwd to be verified and the parsed random factor SALT to obtain an operation RESULT checkusult = MD5 ($ checkwd + $ SALT), then the operation RESULT $ checkusult is compared with the obtained inverse mapping RESULT $ RESULT, if the operation RESULT $ checkusult is completely consistent, verification is successful, the password string is right, and if the operation RESULT $ checkusult is not completely consistent, verification is failed, and the password string is wrong.
As long as the original character string and the KeyMap can be converted in a reversible way, other information can be fused and stored in other fields, the purpose of saving space is achieved, and the method is not limited to password verification. The method has a good reference function for the embedded equipment with a short storage space.
As shown in fig. 2, an embodiment of the present invention further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the MD 5-based encryption and fusion storage method described above.
As shown in fig. 3, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements an MD 5-based encryption fusion storage method as described above.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes may be made to the present invention by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. An encryption fusion storage method based on MD5 is characterized by comprising the following steps:
step 1, extracting all possible different characters according to the characteristic of a final storage value of an MD5 algorithm, and acquiring different characters to perform mapping coding on each extracted character to obtain a key mapping table;
step 2, obtaining a password string to be encrypted;
step 3, calculating the number n of the characters occupied by the random factors at most, wherein n is a positive integer; randomly acquiring m characters from all extracted and acquired characters as random factors, wherein m is more than or equal to 1 and less than or equal to n, and m is a positive integer;
step 4, calculating the password string and the random factor through an MD5 algorithm to obtain a calculation result;
step 5, randomly sequencing all extracted and obtained characters, and determining a binary index value corresponding to each character in the random factor according to the sequencing, the total number of all extracted and obtained characters to obtain a binary index value string of the random factor;
step 6, comparing the binary index value string of the random factor with the calculation result, mapping according to that each two binary index values correspond to one character, searching a key mapping table, replacing the character corresponding to the calculation result, and obtaining a fusion result of the binary index value string of the random factor and the calculation result;
and 7, storing the fusion result.
2. The MD 5-based encryption fusion storage method according to claim 1, wherein the step 1 specifically comprises:
step 11, extracting all possible 16 different characters as keys according to the characteristic of the final storage value of the MD5 algorithm;
step 12, acquiring 48 different characters as values;
step 13, mapping and coding 64 different characters in key-value distributed storage, wherein each key corresponds to a unique value, each key is provided with one character, each value is provided with three characters, and each character can only be used once;
step 14, setting each key and one value as a group, wherein each group is provided with 4 characters, the first character is the key, and the last three characters are the values; each character of each group is indexed by 2-bit binary, wherein 00 represents a first character, 01 represents a second character, 10 represents a third character, and 11 represents a fourth character, so as to obtain a key mapping table.
3. The MD 5-based encryption fusion storage method according to claim 2, wherein the step 3 specifically includes:
step 31, calculating results by an MD5 algorithm to be 32 characters, setting each character to have a 2-bit binary fusion storage space, and enabling the 32 characters to correspond to a 64-bit binary fusion storage space;
step 32, indexing 64 different characters by using a 6-bit binary system at least, wherein the fusion storage space of the 64-bit binary system can only store 10 characters at most, the length of the 10 characters is minimum and needs the 4-bit binary system to represent, and the number n of the characters occupied by the random factor at most is calculated to be 10;
and step 33, randomly acquiring m characters from 64 different characters as random factors, wherein m is more than or equal to 1 and less than or equal to 10, and m is a positive integer.
4. The MD 5-based encryption fusion storage method according to claim 3, wherein the step 5 specifically comprises:
step 51, indexing 64 different characters by using a 6-bit binary system at least, randomly sequencing the 64 different characters, and respectively indexing the 64 different characters by using the 6-bit binary system according to the sequence;
step 52, converting each character of the random factor by using a corresponding 6-bit binary index value;
step 53, if the number m of the characters occupied by the random factor is within the range that m is more than or equal to 1 and less than 10, the missing part is complemented in the back by using a random 6-bit binary system to obtain a complete 60-bit binary index value; if the number m =10 of the characters occupied by the random factor, the completion is not needed;
step 54, expressing the number m of the characters occupied by the random factor by using a 4-bit binary system, and placing the number m at the last position;
and step 55, combining the complete 60-bit binary index value with the 4-bit binary corresponding to the character number m occupied by the random factor to obtain a 64-bit binary index value string of the random factor.
5. The MD 5-based encryption fusion storage method according to claim 4, wherein the step 6 specifically includes:
step 61, comparing the 64-bit binary index value string of the random factor with 32 characters of the calculation result, wherein each 2-bit binary index value corresponds to 1 character;
step 62, judging whether 1 character corresponding to the 2-bit binary index value needs to be replaced according to the position corresponding to each 2-bit binary index value, if the 2-bit binary index value is 00, indicating that the character is located at the key position of the row corresponding to the character, and keeping the corresponding character unchanged; if the 2-bit binary index value is 01, indicating that the character is located at the value position of the corresponding line of the character, replacing the corresponding character with the first character at the value position; if the 2-bit binary index value is 10, indicating that the character is located at the value position of the corresponding line of the character, replacing the corresponding character with a second character at the value position; if the 2-bit binary index value is 11, indicating that the character is located at the value position of the row corresponding to the character, replacing the corresponding character with a third character at the value position;
step 63, searching a key mapping table, and replacing characters corresponding to the calculation result;
and step 64, after all characters corresponding to the calculation result are replaced, obtaining a final fusion result of the random factor binary index value string and the calculation result.
6. The MD 5-based encryption fusion storage method according to claim 1, wherein the step 7 specifically includes:
and storing the fusion result in the original position of the database.
7. The MD 5-based encryption fusion storage method according to claim 2, further comprising after step 7:
and 8, reversely analyzing a random factor and a reverse mapping result, wherein the reverse mapping result is a calculation result of the original password string and the random factor calculated by the MD5 algorithm, calculating the password string to be verified and the random factor by the MD5 algorithm to obtain an operation result, and verifying the password string to be verified according to the comparison operation result and the reverse mapping result.
8. The MD 5-based encryption fusion storage method according to claim 7, wherein the step 8 specifically includes:
step 81, obtaining a final stored fusion result;
step 82, searching a key mapping table to completely analyze the 64-bit binary index value string hidden in the fusion result;
step 83, calculating the character number m of the random factor according to the last 4-bit binary numerical value in the analyzed 64-bit binary index value string;
step 84, resolving m characters represented by the previous 6 x m-bit binary index value in the 64-bit binary index value string according to the calculated character number m of the random factor and corresponding to 1 character according to the 6-bit binary index value to obtain a final random factor;
step 85, searching the character at the value position in the fusion result according to the key mapping table, reversely mapping the character at the value position to the character at the key position corresponding to the row of the character, and obtaining a reverse mapping result;
and 86, performing MD5 calculation on the password string to be verified and the analyzed random factor to obtain an operation result, then comparing the operation result with the obtained reverse mapping result, if the operation result is completely consistent with the obtained reverse mapping result, indicating that the verification is successful, the password string is right, and if the operation result is not completely consistent with the obtained reverse mapping result, indicating that the verification is failed, and the password string is wrong.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements an MD 5-based encryption fusion storage method according to any one of claims 1 to 8 when executing the program.
10. A computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements an MD 5-based encryption fusion storage method according to any one of claims 1 to 8.
CN202211273932.4A 2022-10-18 2022-10-18 Encryption fusion storage method, device and medium based on MD5 Pending CN115577374A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211273932.4A CN115577374A (en) 2022-10-18 2022-10-18 Encryption fusion storage method, device and medium based on MD5

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211273932.4A CN115577374A (en) 2022-10-18 2022-10-18 Encryption fusion storage method, device and medium based on MD5

Publications (1)

Publication Number Publication Date
CN115577374A true CN115577374A (en) 2023-01-06

Family

ID=84584209

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211273932.4A Pending CN115577374A (en) 2022-10-18 2022-10-18 Encryption fusion storage method, device and medium based on MD5

Country Status (1)

Country Link
CN (1) CN115577374A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117375627A (en) * 2023-12-08 2024-01-09 深圳市纷享互联科技有限责任公司 Lossless compression method and system for plain text format data suitable for character strings

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117375627A (en) * 2023-12-08 2024-01-09 深圳市纷享互联科技有限责任公司 Lossless compression method and system for plain text format data suitable for character strings
CN117375627B (en) * 2023-12-08 2024-04-05 深圳市纷享互联科技有限责任公司 Lossless compression method and system for plain text format data suitable for character strings

Similar Documents

Publication Publication Date Title
US10778441B2 (en) Redactable document signatures
CN106161006B (en) Digital encryption algorithm
US9514330B2 (en) Meta-complete data storage
US8891768B2 (en) Increasing data security in enterprise applications by obfuscating encryption keys
CN112597480B (en) Implementation mode of extensible format reservation encryption method
JP2021513141A (en) Generation and identification of 2D barcodes
CN106610995B (en) Method, device and system for creating ciphertext index
US20180248689A1 (en) Password generation with key and derivation parameter
WO2014092183A1 (en) Bit string matching system, method, and program
CN111767565B (en) Data desensitization processing method, processing device and storage medium
CN107612692A (en) A kind of information processing method, device and storage medium
JPWO2013005825A1 (en) Information processing apparatus, information processing method, and program
CN115577374A (en) Encryption fusion storage method, device and medium based on MD5
WO2022042103A1 (en) Data protection method, device, equipment, and medium
CN107634765A (en) A kind of Internet of Things coding method and system
US20030016820A1 (en) System and method for data encryption
CN114218582A (en) Database data encryption method and terminal
Wang et al. Password authentication using Hopfield neural networks
CN111291001A (en) Reading method and device of computer file, computer system and storage medium
CN114968206A (en) Dynamic confusion method and system for programming language codes
CN114579637A (en) Efficient retrieval method for block chain of power grid service system
CN111523885B (en) Encryption multi-account construction method for blockchain wallet, computer readable storage medium and blockchain encryption multi-account wallet
US11281688B2 (en) Ranking and de-ranking data strings
RU2259639C2 (en) Method for complex protection of distributed information processing in computer systems and system for realization of said method
CN112287374A (en) Excel ciphertext document recovery method, computer equipment and storage medium

Legal Events

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