1
00:00:06,360 --> 00:00:07,410
- [Instructor] In this segment,

2
00:00:07,410 --> 00:00:09,690
we're gonna look at creating hash values,

3
00:00:09,690 --> 00:00:12,330
also called fingerprints, message digest

4
00:00:12,330 --> 00:00:15,090
and sometimes just hashes.

5
00:00:15,090 --> 00:00:18,300
And we use hashing
algorithms to create unique,

6
00:00:18,300 --> 00:00:22,680
one-way fixed length output
from variable length input.

7
00:00:22,680 --> 00:00:26,460
Now to create a hash value,
you use a hash calculator.

8
00:00:26,460 --> 00:00:28,680
So let's take a look at a hash calculator.

9
00:00:28,680 --> 00:00:30,570
The cryptographic hash algorithms

10
00:00:30,570 --> 00:00:31,950
which is what we're going to use

11
00:00:31,950 --> 00:00:34,950
produce irreversible and unique hashes.

12
00:00:34,950 --> 00:00:37,530
Unique means that two different pieces

13
00:00:37,530 --> 00:00:40,860
of data can never produce the same hash

14
00:00:40,860 --> 00:00:44,520
which is why hashing can
be used to prove integrity.

15
00:00:44,520 --> 00:00:47,280
Now this particular hash
calculator offers a variety

16
00:00:47,280 --> 00:00:49,020
of hashing algorithms.

17
00:00:49,020 --> 00:00:53,010
The current US government
standard is the SHA algorithm.

18
00:00:53,010 --> 00:00:56,250
SHA stands for secure hashing algorithm.

19
00:00:56,250 --> 00:00:58,710
Now, there are three families, SHA-1

20
00:00:58,710 --> 00:01:03,710
which was effectively retired
in 2015, the SHA-2 family

21
00:01:03,870 --> 00:01:08,700
which includes SHA-256,
SHA-384, and SHA-512

22
00:01:08,700 --> 00:01:10,953
and the emerging SHA-3 family.

23
00:01:12,150 --> 00:01:13,410
So let's select all

24
00:01:13,410 --> 00:01:16,380
of these just so we can have a comparison.

25
00:01:16,380 --> 00:01:20,070
So I'm gonna choose the
message digest family,

26
00:01:20,070 --> 00:01:22,770
the SHA family, then RIPEMD,

27
00:01:22,770 --> 00:01:25,923
PANAMA, TIGER, MD2 and Adler.

28
00:01:27,780 --> 00:01:29,820
And I'm going to put in a text string.

29
00:01:29,820 --> 00:01:31,530
It was a bright cold day in April

30
00:01:31,530 --> 00:01:33,693
and the clocks were striking 13.

31
00:01:34,710 --> 00:01:37,350
And now I'm gonna choose calculate.

32
00:01:37,350 --> 00:01:38,610
And you can see that each one

33
00:01:38,610 --> 00:01:43,050
of these created a different hash value.

34
00:01:43,050 --> 00:01:44,160
Now there are different lengths

35
00:01:44,160 --> 00:01:46,410
depending upon the number of bits

36
00:01:46,410 --> 00:01:48,063
and different construction.

37
00:01:49,290 --> 00:01:51,120
So does length matter?

38
00:01:51,120 --> 00:01:53,010
Well, technically, yes.

39
00:01:53,010 --> 00:01:56,580
You know, a bit has two
possible values, zero and one.

40
00:01:56,580 --> 00:01:59,670
So the possible number of
unique hashes can be expressed

41
00:01:59,670 --> 00:02:03,600
as a number of possible values
raised to the number of bits.

42
00:02:03,600 --> 00:02:05,340
So a SHA-256, well,

43
00:02:05,340 --> 00:02:10,260
there are 2 to 256 possible combinations.

44
00:02:10,260 --> 00:02:11,820
That would be 2 of 384.

45
00:02:11,820 --> 00:02:14,070
It would be 2 to the 384th.

46
00:02:14,070 --> 00:02:16,740
512 would be 2 to the 512.

47
00:02:16,740 --> 00:02:18,660
Those are huge, huge numbers.

48
00:02:18,660 --> 00:02:21,240
Matter of fact, 2 to the 256.

49
00:02:21,240 --> 00:02:23,070
Well, the example you often hear

50
00:02:23,070 --> 00:02:25,320
is that it exceeds the number of grains

51
00:02:25,320 --> 00:02:27,540
of sand that there are in the world.

52
00:02:27,540 --> 00:02:30,150
Now the larger the number
of possible hashes,

53
00:02:30,150 --> 00:02:31,350
the smaller the chance

54
00:02:31,350 --> 00:02:34,440
that two values will create the same hash.

55
00:02:34,440 --> 00:02:37,290
Now, a large bit length
doesn't automatically, however,

56
00:02:37,290 --> 00:02:40,770
mean that a hashing algorithm
produces more secure hash.

57
00:02:40,770 --> 00:02:41,603
The construction

58
00:02:41,603 --> 00:02:44,400
of the algorithm is also
incredibly important

59
00:02:44,400 --> 00:02:46,470
which is why we use hashing algorithms

60
00:02:46,470 --> 00:02:49,713
that are specifically designed
for cryptographic security.

61
00:02:50,820 --> 00:02:51,930
Now let's look at what happens

62
00:02:51,930 --> 00:02:54,870
if I make even the slightest change.

63
00:02:54,870 --> 00:02:59,250
I want you to focus in on
any one of those outputs

64
00:02:59,250 --> 00:03:02,100
and just look at maybe the
last three or four characters.

65
00:03:02,100 --> 00:03:03,840
Choose any one you want.

66
00:03:03,840 --> 00:03:06,120
And what I'm gonna do is
I'm gonna come back up

67
00:03:06,120 --> 00:03:09,930
to my data input, and I'm
gonna change that last period

68
00:03:09,930 --> 00:03:14,220
to an explanation point, and
we're gonna calculate it again.

69
00:03:14,220 --> 00:03:19,170
And what you should see now
is a different output, right?

70
00:03:19,170 --> 00:03:23,010
Because if we make the slightest
change, we add a space,

71
00:03:23,010 --> 00:03:26,040
we change the punctuation,
we add a letter,

72
00:03:26,040 --> 00:03:29,160
we take a letter away, we
take a letter that's lowercase

73
00:03:29,160 --> 00:03:33,180
and make it uppercase, and it
will change the output, right?

74
00:03:33,180 --> 00:03:34,950
And it's absolutely critical

75
00:03:34,950 --> 00:03:38,493
that the output is unique to that input.

76
00:03:41,280 --> 00:03:44,220
Now you also see we have
an option of doing an HMAC.

77
00:03:44,220 --> 00:03:49,220
Now, a HMAC is when we add a
symmetric key to the input.

78
00:03:50,220 --> 00:03:51,510
Now, why would we do that?

79
00:03:51,510 --> 00:03:54,420
Well, that means that both
parties have to be communicating

80
00:03:54,420 --> 00:03:57,330
because symmetric key means
single key or a shared key.

81
00:03:57,330 --> 00:04:00,600
So both parties are going
to have to be in possession

82
00:04:00,600 --> 00:04:03,960
of that key, and they'll take the input

83
00:04:03,960 --> 00:04:07,440
as well as the key to produce the hash

84
00:04:07,440 --> 00:04:09,090
and then they'll compare that.

85
00:04:09,090 --> 00:04:13,050
So I'm just gonna show you
how we're going to do an HMAC.

86
00:04:13,050 --> 00:04:15,060
I've got that same data string.

87
00:04:15,060 --> 00:04:19,923
I'm just gonna add a key
and then I'll calculate.

88
00:04:22,080 --> 00:04:25,230
So all the calculator's
doing is it's taking the data

89
00:04:25,230 --> 00:04:29,283
plus the key in order
to produce the output.

90
00:04:31,350 --> 00:04:32,430
Very straightforward.

91
00:04:32,430 --> 00:04:35,100
You can find hash calculators online

92
00:04:35,100 --> 00:04:37,980
or you can bring down a local application.

93
00:04:37,980 --> 00:04:42,060
But understanding that we use
hashing to prove integrity

94
00:04:42,060 --> 00:04:43,920
that the uniqueness is important

95
00:04:43,920 --> 00:04:47,460
that if we don't have uniqueness,
it's called a collision.

96
00:04:47,460 --> 00:04:50,730
And once we start having
collisions, we can no longer depend

97
00:04:50,730 --> 00:04:54,810
upon that hashing algorithm
to prove integrity.

98
00:04:54,810 --> 00:04:57,480
And that my friends is a closer look

99
00:04:57,480 --> 00:04:59,013
at creating hash values.
