Lecture-15 program to detect double space
Lecture-15 program to detect double space
Lecture # 15
1
Objectives
• Introduction to Hash Functions.
2
Hash Functions
How Does a Hash Function Work?
• A hash function depends on the algorithm but
generally, to get the hash value of a set length, it
needs to first divide the input data into fixed-sized
blocks, which are called data blocks.
3
Hash Functions (Cont..)
• This is because a hash function takes in data at a
fixed length.
4
Hash Functions (Cont..)
• This is because a hash function takes in data at a
fixed length.
5
Hash Functions (Cont..)
• If the blocks are not big enough, they may add
padding to fill it out.
6
Hash Functions (Cont..)
7
Hash Functions (Cont..)
The “Avalanche Effect”:
• The data blocks are processed one at a time.
8
Hash Functions (Cont..)
The “Avalanche Effect”:
• Thus, making the final output the combined value of
all the blocks.
9
Hash Functions (Cont..)
Uniqueness and Deterministic:
• There should be no chance whatsoever that two
different message inputs create the same output hash.
10
Hash Functions (Cont..)
Irreversibility:
• Ideally, hash functions should be irreversible.
11
Hash Functions (Cont..)
12
Hash Functions (Cont..)
Brute Force Search:
• However, it is possible to compute the input given the
output hash value, and that involves lots of
computing power.
13
Hash Functions (Cont..)
Hash Functions in Cryptography:
• The most famous cryptocurrency, Bitcoin, uses hash
functions in its blockchain.
14
Hash Functions (Cont..)
Hash Functions in Cryptography:
• Solving a hash involves computing a proof-of-work,
called a NONCE, or “number used once”, that,
when added to the block, causes the block’s hash to
begin with a certain number of zeroes.
15
Hash Functions (Cont..)
Hash Functions in Cryptography:
• Since each block’s hash is created by a cryptographic
algorithm – Bitcoin uses the SHA-256 algorithm –
the only way to find a valid proof-of-work is to run
guesses through the algorithm until the right number
is found that creates a hash that starts with the right
number of zeroes.
16
Hash Functions (Cont..)
Hash Functions in Cryptography:
• This is what Bitcoin miners are doing, running
numbers through a cryptographic algorithm until they
guess the valid NONCE.
17
Hash Functions (Cont..)
Common Cryptocurrency Hash Functions:
• The SHA-256 function that Bitcoin uses is short for
“Secure Hash Algorithm” and was designed by the
United States National Security Agency (NSA) and
includes SHA-1, SHA-2 (a family within a family
that includes SHA-224, SHA-256, SHA-384, and
SHA-512), and SHA-3 (SHA3-224, SHA3-256,
SHA3-384, and SHA3-512).
18
Hash Functions (Cont..)
Common Cryptocurrency Hash Functions:
• Message Digest (MD) Algorithm — MD2, MD4,
MD5, and MD6. MD5 was long considered a go-to
hashing algorithm, but it’s now considered broken
because of hash collisions.
19
Hash Functions (Cont..)
Common Cryptocurrency Hash Functions:
• Windows NTHash — Also known as a Unicode
hash or NTLM, this hash is commonly used by
Windows systems
20
Hash Functions (Cont..)
• Any piece of digital information, like a file on your
computer, a photo on your smartphone, or a block on
a cryptocurrency blockchain, has a hash. And each
hash is unique to each piece of data – any small
change in the underlying information will lead to a
completely different hash.
21
Hash Functions (Cont..)
Hashing vs Encryption:
• Encryption is the practice of taking data and creating
a scrambled message in a way that only someone
with a corresponding key, called a cipher, can
unscramble and decode it.
22
Hash Functions (Cont..)
Hashing vs Encryption:
• Encryption is a two-way function, designed to be
reversible by anyone who holds a cipher.
23
Hash Functions (Cont..)
Hashing vs Encryption:
• Hashing is using a formula that converts data of any
size to a fixed length.
24
Hash Functions (Cont..)
Hashing vs Encryption:
• Encryption is meant to protect data in transit, hashing
is meant to verify that a file or piece of data hasn’t
been altered—that it is authentic.
25
Hash Functions (Cont..)
Hashing vs Encryption:
• Encryption is meant to protect data in transit, hashing
is meant to verify that a file or piece of data hasn’t
been altered—that it is authentic.
26
Questions
Any Question Please?
27
Further Readings
• Chapter No. 1
Computer_Security_Principles_and_Practice_(3rd_E
dition)
By William Stallings and Lawrie Brown
28
Thanks
29