If we can't decode the MD5 hash string, then wh开发者_Go百科at is the purpose of MD5 where can we use MD5.
To store data save in a database for example.
If you save your password using md5 and you compare it with the password you enter in a form and hash it, it is still the same password but you can't see it in clear text in the database.
For example:
password = 123
md5(123) === "202cb962ac59075b964b07152d234b70"
if you try to log in and you enter 123 as your password, the md5 of it will still be the same and you can compare those. But if your database is hacked the hacker cannot read the password in clear text, only the hashed value
An decryptable file has the property that its always at least as big as the original file, a hash is much, much smaller.
This allows us the create a hash from a file that can prove the integrity of the file, without storing it.
There are many reasons not to store the file in encrypted or plain text:
As soon as an encrypted file falls in the wrong hands, they could try to decrypt it. There's no chance that's going to happen with a hash.
You simply don't need the file yourself, but maybe you're sending it to someone, and that person can proof it's integrity using the hash.
It allows you to determine whether the data you have (e.g., an entered password) is the same as some other data which is secret (e.g., the correct password) without requiring access to the secret data. In other words, it can be used to determine "is this user-entered password correct?" while also keeping the correct password secret. (Note that there are stronger hashing methods out there which should be used instead of md5 for this purpose these days, such as sha* and bcrypt. With modern hardware, it's fairly easy to throw millions of passwords per second at an md5 hash until you find one that matches the correct password.)
It allows you to verify the integrity of a transmitted file by comparing the md5 hash of the original file with the md5 hash of the data that was received. If the hashes are different, the received data was not the same as the sent data, so you know to re-send it; if they're the same, you can be reasonably certain that the sent and received data are identical.
Good hash functions like MD5 can be used for identification. See this question. Under certain conditions you can assume that equal hashes mean equal data blocks.
MD5 is mainly used to maintain the integrity of files when it is send from 1 machine to another machine,to detect whether any man in middle third party have not modify the contents of files.
Basic example is : When you download any file from server server has MD5 calculated when it comes to you it again check for md5 values if md5 hash matches file is not corrupted or not modified by any third person.
MD5 is a hash function and there are more like that such as SHA, PBKDF, bcrypt and scrypt. I really prefer scrypt. Hash functions are used for integrity reasons in order to detect any manipulations that may occurred during the transmission of the actual message. The receiver is able to find if the received message has not not changed by checking the hash value of the message.
These functions have three security properties: 1) It is difficult for someone to detect the actual message when it only has the h(m). 2) Given a message m and its hash function it is difficult to find another message with the same hash value. 3) Last, it is difficult to find to different messages m1, m2 with the same hash value.
Also, it is important to know that hash function's algorithms are public and it is very easy to compute the hash value of a message. Moreover, hashes are "one-way" functions, meaning that is hard to find the message given the hash of the message. The actual security thus, is based on that property.
精彩评论