You are on page 1of 14

Kingdom of Saudi Arabia

Ministry of Higher Education


Al-Imam Muhammad Ibn Saud Islamic University
College of Computer and Information Sciences

Hash Tutorial
Hash Algorithm
• A hash algorithm is a oneway function that converts a
data string into a numeric string output of fixed length. The
output string is generally much smaller than the original
data. Therefore, it is also called message digest or
message compression algorithm.
• Hash algorithms are designed to be collisiaon-resistant,
meaning that there is a very low probability that the same
string would be created for different data.
One-way Hash Function
• The notion of a one-way function is central to public-key
cryptography.
• A one-way hash function is a mathematical function which
takes a variable-length input string (called pre-image) and
converts it into a fixed-length binary sequence (called
hash value).
• It is also known as a message digest, fingerprint or
compression function
• Furthermore, a one-way hash function is designed in such
a way that it is hard to reverse the process, that is, it is
easy to compute a hash value from pre-image but it is
hard to generate a pre-image that hashes to a particular
value.
Hash Function
Fundamentally, Hashing is defined by
two distinct characteristics
Irreversibility Uniqueness

• Irreversibility points to the • Unique, because no two


fact that once you hash hash values are ever the
something, there is no same for two different
way back. Unlike pieces of data. If two
Encryption and Encoding, hashes are found to be
you can’t easily dehash a the same for two different
message/data. pieces of data, it’s called
a ‘hash collision’ and that
algorithm becomes
useless.
Popular Hashing algorithms
• Two of the most common hash algorithms are the MD5
(Message-Digest algorithm 5) and the SHA-1 (Secure
Hash Algorithm). MD5 Message Digest checksums are
commonly used to validate data integrity when digital files
are transferred or stored.
• md5sum – compute and check MD5 (128-bit) message
digest
• sha1sum – compute and check SHA1 (160-bit) message
digest
HASH FUNCTION
• Most popular types of hashes:
• MD5
• SHA1
• SHA256
• SHA512

7
Hash Algorithms in Mac
1. Open Terminal
2. Write the hash algorithm “MD5 or SHASUM”
3. Add the file path or drag and drop the file into the
terminal
• Note that the hash algorith remains the same, unliss the file was
updated
• The hash length depends on the hash alorithm
• MD5 has a length of 128 bits
Hash Algorithms in Mac
HASH for Windows

certutil -hashfile "filename.exe" MD5

certutil -hashfile "filename.exe" SHA1

certutil -hashfile "filename.exe" SHA256

certutil -hashfile "filename.exe" SHA512

10
Using Command Prompt
Open a command line prompt. To do this, click the Start menu button
and type "cmd" (without the quotation marks). The words "Command
Prompt" should appear at the top of the menu. Click it to run it.
You will see a black window with a title bar that says "Command
Prompt", and a blinking text cursor just after words that say something
like "c:\Users\User>" somewhere in the window. (The exact words will
not be the same, since your Windows account name will probably be
different from mine.)

11
• Now navigate to the directory or folder where you have placed your file.
If your file is on the desktop, type "cd desktop" (without the quotation
marks) and hit the ENTER key. Otherwise, change directory by typing
"cd" followed by the full path.

12
• To use the Hash function, choose one of the hash
algorithms mentioned in slide 10. and write the command
as shown below:

• Now open the same file. ADD only one space to the first line. Go back
to the command prompt and write the same function. What do notice!

Chapter 1 - Introduction 13
Try different hash algorithm..

14

You might also like