A cryptographic hash function is a mathematical formula that helps you convert a given value to other
string value that is reversible.
The resulting value after hashing is smaller compared to the data that passed through the function.
Often these strings have fixed length as you can see it on the screen.
The input varies from Fox to the red fox jumps over the Blue Dog.
We are using the same cryptographic hash function and the resulting hash or message digest is of the
same length.
Even if we change one character like between this input here the Reds fox jumps over the Blue Dog and
between this input here where we remove the V the resulting value is a totally different hash.
So in other words hashes are fingerprints of some data and it's about random looking characters that
uniquely identify the data in question.
What can we hash if you look here at the right picture.
You can hash anything you can hash text sentence password you can hash a file you can hash an empathy
file you can hash any kind of file like ISO files anything we use hashes for three purposes so many
to verify files so Suffolk raters often take your file download and run it through a hash function and
then they on their official site the hash and the file to download.
So in order for you to verify that you've downloaded the right file it hasn't been compromised or infected
with malware you just download the file and generate its hash and compare the hashes that are found
on the website and the hashes that you generate.
And if this match then you have downloaded the right file.
Let's take a simple example here.
If you opened both show and let's go here to the root see.
Suppose that you don't know that this file here and you just want to get the hash of this file in order
to know that this file has not been compromised.
You can do this by running this command.
Get file hash and then the name or the file.
And here you go.
You will get this hash.
Now you just have to compare it with the hash found on the website that you've downloaded the file from.
And if there is a match then this is the original file.
The other purpose is for password storage.
So there are two ways passwords are typically stored on a computer Web site.
The first is in plaintext and if a crook steals a plain text database with passwords they will be able
to see the passwords in clear text.
And this is so wrong.
So the best way to store passwords is to hash them first when you first create a password on a secure
system.
It hashes the password before storing it so it does not store your actual password in the database.
It stores the hash of the password and forgets what you actually typed the next time you type in your
password hashes what you typed in and compare the hash that it generated with the hash that is stored
in the database.
And if there is a match you will be granted an access.
This is so valuable because of the hashes or if the hash database is stolen it can be read by the bad
guys supposedly.
Instead of seeing a list of passwords they will see a list of hashes that can be useless.
The third type of usage is database searching so hashing can speed up the process of searching through
a database so that we storing a long list of names in a table and we need to find a certain name as
in that list.
Well the computer can do a search for the name of course but that might be a long process because it
has to match a large string of characters.
So we can significantly shorten that time by creating a hash for every name on the list.
And as long as the House is shorter than the average name length then this choice will be faster and
easier.
Here are the list of mostly used hashes.
We have a such a 1 2 5 6 512 and the 4 and 5 L M and and tell them each to produce a different length
of hashes and characters.
And here are some of the examples.
It's good to know that difference between encryption and hashing encryption is a two way function.
Data is encrypted with the purpose of being decrypted at a later time and this is the only good way
to store and move data in a secure fashion.
Meanwhile hashing is never meant to be reversed.
It's a one way thing so it's not meant to be secure away or distort or move data but it's a purely used
as an easy way to compare data or compare blocks of data as you might have realized there is a problem
with hashing since they produce a fixed length value.
And we have a finite number of hashes for each type of algorithm which makes collisions possible.
So a collision is when two different data or inputs of data produce the same exact hash.
This is rare but it happens so naturally the longer the hash value the less likely a collision will
happen.