Some knowledge about MD5

xiaoxiao2021-03-05  22

MD5 Introduction The full name of MD5 is Message-Digest Algorithm 5, invented by MIT's computer science laboratories and RSA Data Security Inc invented by MD2, MD3 and MD4 in the 1990s. Message-Digest's Hash transform of the message is to convert an arbitrary length byte string into a certain long integer. Please note that I use the word "byte string" instead of "string" because this transformation is only related to the value of the byte, regardless of the character set or encoding method. MD5 converts any length of "byte string" into a 128bit big integer, and it is an irreversible string transform algorithm. SOLMINAL, even if you see the source program and algorithm description, it is impossible to put a MD5 The value change back to the original string, from the principle of mathematics, because the original string has endless, this is a bit like a mathematical function that does not exist in the reverse function. The typical application of MD5 is to generate FingerPrint (fingerprints) for a Message to prevent tampering. For example, you write a word in a readme.txt file, and generate a MD5 value for this readme.txt and record it, then you can spread this file to others, others modify the file Anything, you will find this file to recalculate MD5. If there is another third party certification body, use MD5 to prevent "reliability" of the author, this is the so-called digital signature application. MD5 is also widely used in encryption and decryption techniques. In many operating systems, the user's password is saved in MD5 value (or similar algorithm), when the user login, the system is calculated into the user input. The MD5 value is then compared to the MD5 value saved in the system, and the system does not "know" what the user's password is. Some hacking methods of cracked this password are a method called "running". There are two ways to get a dictionary, one is a character string table for daily collections, the other is to generate the MD5 value of these dictionaries with the MD5 program, and then use the target The MD5 value is retrieved in this dictionary. Even if the maximum length of the password is assumed to be 8, the password can only be a letter and a number, a total of 26 26 10 = 62 characters, and the number of items that are arranged in combination is P (62, 1) p (62, 2) .... P (62, 8), it is already a very an astronomical number, storing this dictionary requires a TB level disk group, and this method has a premise, it is to get the password of the target account. MD5 value can be used. In many e-commerce and community applications, manage users' Account is the most common basic feature, although many Application Server provides these basic components, but many application developers are more flexible to manage, but also use relational databases. To manage users, lazy approach is that the user's password is often saved directly in the database after using clear text or simple transform, so these users can say that the software developer or system administrator can say that there is no confidentiality, this article The purpose is to introduce the implementation of the Java Bean of the MD5, and give examples of the MD5 to handle the user's Account password, which makes the administrator and programmer can't see the user's password, although they can initialize them. But important points are the protection of habits for user passwords. Interested readers can get MD5 herein is the text of RFC 1321.

Http://www.ieetf.org/rfc/rfc1321.txt // --------------------------------- -------------------------------- MD5 algorithm illustrated one, the completion of the two, the data length is three, initialization MD5 Number 4, processing bit operation function 5, main transformation process 6 That is, data is expanded to K * 512 448 bits. That is, k * 64 56 bytes, K is an integer. Specific complex operation: make up one 1, then supplement 0 to satisfy the above requirements. Supplement data length: uses a 64-bit number to represent the original length B of the data, indicate B with two 32 digits. At this time, the data is filled with a multiple of 512 bits. Initializing MD5 parameters: four 32-bit integers (A, B, C, D) used to calculate information summary, initialization is a hexadecimal representation of the number A = 0x01234567b = 0x89AbcDefc = 0xfedcba98d = 0x76543210 processing bit operation function: x , Y, Z is 32-bit integers. F (x, y, z) = x & y | NOT (x) & zg (x, y, z) = x & z | y? (Z) h (x, y, z) = x xor y xor zi (x, y, Z) = y xor (x | not (z)) main transformation process: use constant group T [1 ... 64], T [i] is 16 32-bit integers with 16 bits, data use 16 32 bits Integer array M [] is represented.

The specific process is as follows: / * Processing data original * / for i = 0 to n / 16-1 do / * Each time, store the data original text in the array X of 16 elements. * / For j = 0 to 15 doset X [j] to m [i * 16 j] .end / end to J's loop / * Save A AA, B AS BB, C AS CC, And D AS DD. * / AA = ABB = BCC = CDD = D / * The first round * // * is indicated by [ABCD KSI] A = B ((A F (B, C, D) X [K] T [I]) <<< S) * // * do the folload 16 Operations. * / [Abcd 0 7 1] [DABC 1 12 2] [CDAB 2 17 3] [BCDA 322 4] [ABCD 4 7 5] [DABC 5 12 6] [CDAB 6 17 7] [ABCD 8 7 9] [CDAB 10 17 11] [BCDA11 22 12] [ABCD 12 7 13] [DABC 13 12 14] [CDAB 14 17 15] [BCDA 15 22 16] / * The second round * * // * is indicated by [ABCD KSI] A = B ((A G (B, C, D) X [K] T [i] <<< s). * // * do the folload 16 Operations. * / [Abcd 1 5 17] [DABC 6 9 18] [CDAB 11 14 19] [BCDA0 20 20] [ABCD 5 5 21] [DABC [CDAB 15 14 23] [ABCD 9 5 25] [DABC 14 9 26] [CDAB 3 14 27] [BCDA8 20 28] [ABCD 13 5 29] [DABC 2 9 30 ] [CDAB 7 14 31] / * The third round * // * is shown in [Abcd KSI] A = B ((A H (B, C, D) X [K] T [I]) <<< s). * // * DO [ABCD 5 4 34] [CDAB 11 16 34] [BCDA 14 23 36] [ABCD 1 4 37] [DABC 4 11 38] [CDAB 7 16 39] [ BCDA10 23 40] [DABC 0 11 42] [BCDA 6 23 44] [ABCD 9 4 45] [DABC 12 11 46] [CDAB 15 16 47] [BCDA 2 23 48] / * The 4th round * // * is represented by [ABCD KSI] A = B ((A I (B, C, D) X [K] T [I]) <<<

转载请注明原文地址:https://www.9cbs.com/read-37642.html

New Post(0)