- [Instructor] In this segment,
we're gonna look at creating hash values,
also called fingerprints, message digest
and sometimes just hashes.
And we use hashing algorithms to create unique,
one-way fixed length output from variable length input.
Now to create a hash value, you use a hash calculator.
So let's take a look at a hash calculator.
The cryptographic hash algorithms
which is what we're going to use
produce irreversible and unique hashes.
Unique means that two different pieces
of data can never produce the same hash
which is why hashing can be used to prove integrity.
Now this particular hash calculator offers a variety
of hashing algorithms.
The current US government standard is the SHA algorithm.
SHA stands for secure hashing algorithm.
Now, there are three families, SHA-1
which was effectively retired in 2015, the SHA-2 family
which includes SHA-256, SHA-384, and SHA-512
and the emerging SHA-3 family.
So let's select all
of these just so we can have a comparison.
So I'm gonna choose the message digest family,
the SHA family, then RIPEMD,
PANAMA, TIGER, MD2 and Adler.
And I'm going to put in a text string.
It was a bright cold day in April
and the clocks were striking 13.
And now I'm gonna choose calculate.
And you can see that each one
of these created a different hash value.
Now there are different lengths
depending upon the number of bits
and different construction.
So does length matter?
Well, technically, yes.
You know, a bit has two possible values, zero and one.
So the possible number of unique hashes can be expressed
as a number of possible values raised to the number of bits.
So a SHA-256, well,
there are 2 to 256 possible combinations.
That would be 2 of 384.
It would be 2 to the 384th.
512 would be 2 to the 512.
Those are huge, huge numbers.
Matter of fact, 2 to the 256.
Well, the example you often hear
is that it exceeds the number of grains
of sand that there are in the world.
Now the larger the number of possible hashes,
the smaller the chance
that two values will create the same hash.
Now, a large bit length doesn't automatically, however,
mean that a hashing algorithm produces more secure hash.
The construction
of the algorithm is also incredibly important
which is why we use hashing algorithms
that are specifically designed for cryptographic security.
Now let's look at what happens
if I make even the slightest change.
I want you to focus in on any one of those outputs
and just look at maybe the last three or four characters.
Choose any one you want.
And what I'm gonna do is I'm gonna come back up
to my data input, and I'm gonna change that last period
to an explanation point, and we're gonna calculate it again.
And what you should see now is a different output, right?
Because if we make the slightest change, we add a space,
we change the punctuation, we add a letter,
we take a letter away, we take a letter that's lowercase
and make it uppercase, and it will change the output, right?
And it's absolutely critical
that the output is unique to that input.
Now you also see we have an option of doing an HMAC.
Now, a HMAC is when we add a symmetric key to the input.
Now, why would we do that?
Well, that means that both parties have to be communicating
because symmetric key means single key or a shared key.
So both parties are going to have to be in possession
of that key, and they'll take the input
as well as the key to produce the hash
and then they'll compare that.
So I'm just gonna show you how we're going to do an HMAC.
I've got that same data string.
I'm just gonna add a key and then I'll calculate.
So all the calculator's doing is it's taking the data
plus the key in order to produce the output.
Very straightforward.
You can find hash calculators online
or you can bring down a local application.
But understanding that we use hashing to prove integrity
that the uniqueness is important
that if we don't have uniqueness, it's called a collision.
And once we start having collisions, we can no longer depend
upon that hashing algorithm to prove integrity.
And that my friends is a closer look
at creating hash values.