Hashing:
Hashing is the
process through which plaintext data of any length is mapped into a unique
ciphertext of fixed length known as a hash. A function that does hashing is a
hash function.
Hashing,
or a hashing
algorithm, is a one-way process that converts your
input data of any size into fixed-length enciphered data.
Hashing uses a hash function to convert standard data into an unrecognizable format. These hash functions are a set of mathematical calculations that transform the original information into their hashed values, known as the hash digest or digest in general. The digest size is always the same for a particular hash function like MD5 or SHA1, irrespective of input size.
How Does Hashing Work?
First of all, the hashing algorithm divides the large input data into blocks of equal size. The algorithm then applies the hashing process to each data block separately.
Although one block is
hashed individually, all of the blocks are interrelated. The hash value of the
first data block is considered an input value and is added to the second data
block. In the same way, the hashed output of the second block is lumped with
the third block, and the combined input value is hashed again. And so on and so
on, the cycle continues until you get the final has output, which is the
combined value of all the blocks that were involved.
That means if any
block’s data is tampered with, its hash value changes. And because its hash
value is fed as an input into the blocks that follow, all of the hash values
alter. This is how even the smallest change in the input data is detectable as
it changes the entire hash value.
Hash Function:
Hash functions are
mathematical functions that transform or "map" a given set of data
into a bit string of fixed size, also known as the "hash value." A hash function
is a one-way mathematical function that converts the input into an
unreadable data string output of a fixed length.
Hash functions in cryptography are highly valuable and may be found in practically every application that deals with information security. A hash value is a like a fingerprint used to reassure the recipient of the received message's integrity.
Hash
functions are the most commonly used mathematical functions in cryptography for
implementing security. A hash function converts an input value of any arbitrary
size to a fixed-size value. Thus, the input can be of any length but the output
generated is always of a fixed length. The output is called a message digest, a hash value, a hash
code or simply a hash.
The Hash function in cryptography
is an algorithm that receives any amount of data input and produces a constant
length output of encrypted text known as a hash value or hash. Hash functions are used for cryptocurrency, password
security, and message security.
A cryptographic hash function is a mathematical function used in
cryptography. Typical hash functions take inputs of variable lengths to return
outputs of a fixed length. It is a function which takes a string of variable length and
encodes as a fixed-length hash value or message digest. Cryptographic hash functions create a particular
length of output independent of the size of the input they obtain.
The length of
the output or hash depends on the hashing algorithm you use. Hash values can be
160 bits for SHA-1 hashes, or 256 bits, 384 bits, or 512 bits for the SHA-2
family of hashes. They’re typically displayed in hexadecimal characters. The
input data’s quantity and size can be varied, but the output value always
remains the same in terms of size.
It is a one-way function, and since there
is no relation between both the text being interpreted and the summary value,
it is difficult to derive the actual data from the summary value received. The
same meaning for the same data is produced in the hash process, but the value
provided by the hash function often varies when there is a minor shift. Digest
functions are typically used in fields such as data integrity authentication,
password storage, digital signature, message verification code, etc. Blockchain
implementations, which are common today, are another field of use.
Ideal cryptographic hash function should be like:
Hashing vs Encryption:
Hashing and encryption are two
separate cryptographic processes. Encryption is something you can use to
convert plaintext (readable) data into something indecipherable using
algorithms and a key. However, you can decrypt that data either by using the
same (symmetric encryption) or a mathematically-different-but-related
cryptographic key (asymmetric encryption).
A cryptographic hash function is
different. Once you hash data, you can’t restore it to its original format
because it’s a one-way process.
Hashing Algorithms:
Hashing algorithms are functions that generate a fixed-length result (the hash, or hash value) from a given input. The hash value is a summary of the original data. A hashing algorithm is a cryptographic hash function. It is a mathematical algorithm that maps data of arbitrary size to a hash of a fixed size.
A hash function
algorithm is designed to be a one-way function, infeasible to invert. However,
in recent years several hashing algorithms have been compromised. This happened
to MD5, for example — a widely known hash function designed to be a
cryptographic hash function, which is now so easy to reverse — that we could
only use for verifying data against unintentional corruption.
A hash algorithm is used to map a message
of arbitrary length to a fixed-length message digest.
The essential features of hash algorithms are:
- These functions cannot be reversed.
- Size of the digest or hash is always fixed and does not depend on the size of the data.
- It is always unique, no two distinct data set are able to produce a similar hash.
What do we use it for?
Cryptographic hash functions are widely used in IT. We can use them for digital signatures, message authentication codes (MACs), and other forms of authentication. We can also use them for indexing data in hash tables, for fingerprinting, identifying files, detecting duplicates or as checksums (we can detect if a sent file didn’t suffer accidental or intentional data corruption).We can also use them for password storage. If you have a website, you most likely do not actually need to store the password of your users. You just need to check whether the user password and the password of any given attempt match, so hashes should work fine and give some additional protection to your users.
In order to keep your security standards, you must always follow the newest technologies, especially when you use hashing algorithms for security.
Features (Characteristics) of Hash Functions:
The Hash function in cryptography is an algorithm that receives any amount of data input and produces a constant length encrypted text output. The encrypted output text is known as a hash value or hash.
Some of the essential features of Hash Functions are:
- The hash function converts data of any arbitrary length to a fixed length. This process is known as hashing the data.
- Generally, the hash is smaller than the input data; hence hash functions are sometimes also known as compression functions.
- Since a hash is a miniature representation of extensive data, it is also known as a digest.
- Hash function having n-bit output is known as an n-bit hash function. Famous hash functions generate values between 160 and 512 bits.
- A Hash Function Is Practically Irreversible. Hashing is often considered a type of one-way function. That’s because it’s highly infeasible (technically possible, though) to reverse it because of the amount of time and computational resources that would be involved in doing so. That means you can’t figure out the original data based on the hash value without an impractical amount of resources at your disposal.
- Hash Values Are Unique. No two different input data should (ideally) generate the same hash value. If they do match, it causes what’s known as a collision, which means the algorithm isn’t safe to use and is vulnerable to what are known as birthday attacks. Collision resistance is something that improves the strength of your hash and helps to keep the data more secure.
Properties of Cryptographic Hash Functions:
The hash function should have the following properties to be an effective cryptographic tool:
This property requires that a hash function H should consistently map a given input m to a hash value h.
Determinism (Deterministic):
Regardless of the size of the input or the key
value, the operation should always result in the same consistent length output
or hash value.
Pre-Image Resistance: (One-way function) :
This property
signifies that it should be computationally tough to reverse a hash function.
It will protect against a hacker who only has a hash value and is trying to
find the input.
This property requires that for a hash function H if given any hash value h, it is computationally infeasible to find an input m such that H(m) = h. In other words, it must be easy to compute on every input but extremely difficult to invert given the image of a random input.
Second Pre-Image Resistance:
This property signifies that if the input and its
hash are given, it should be tough to find a different input with the same
hash. It protects against a hacker with an input value and its hash and wants
to replace the original input value with another legitimate value.
Collision Resistance:
It is computationally infeasible to find two different inputs to the hash function that have the same hash value.
This property signifies that it should be tougher
to find two different inputs of arbitrary length that will result in the same
hash value. This property is known as a collision-free hash function. This
property will create many difficulties for a hacker to find two input values
with the same hash.
Avalanche Effect:
This property requires that a change in just one bit of the input data should result in a large change in the output. This “diffusion” ensures that any inference about the input from the output is infeasible thus this property is also sometimes defined as unruliness.
Hash Speed :
an ideal property of a
cryptographic hash function is its ability to operate at a reasonable speed. In
many situations, a hashing algorithm should compute hash values rather quickly.
However, it’s worthwhile to note that faster is not always better or more
secure.
Message Digest (MD): MD2, MD4, MD5, and MD6 are hash functions in the MD family. It's a hash function with a 128-bit length. MD5 was the most popular and commonly used hash function for many years. MD5 digests are widely used in the software industry to ensure the integrity of transferred files. MD5 was discovered to have collisions in 2004. Using a computer cluster, an analytical attack was reported to be successful in less than an hour. Because of the compromised MD5 resulting from the collision attack, it is no longer recommended for use.
Secure Hash Algorithm (SHA): SHA-0, SHA-1, SHA-2, and SHA-3 are the four SHA
algorithms that make up the SHA family. Despite being from the same family,
they are structurally distinct. The National Institute of Standards and
Technology (NIST) published the original version of SHA-0, a 160-bit hash
function, in 1993. It had few flaws and did not gain widespread popularity.
Later in 1995, SHA-1 was created to address SHA-0's reported faults. Of the
available SHA hash functions, SHA-1 is the most extensively used. It's utilized
in various popular applications and protocols, including the Secure Socket
Layer (SSL) security protocol. The Keccak algorithm was chosen as the new SHA-3
standard by the NIST in October 2012. Keccak has several advantages, including
efficient performance and strong assault resistance.
Applications of Hash Functions:
Based on its
cryptographic features, a hash function has two direct uses:
Password
Storage: Password storage is protected using hash functions. Rather than saving
passwords in plain text, most login processes save hash values of passwords in
a file. A table of pairs in the format (user id, h(P)) makes up the Password
file. Even if he accessed the password, an intruder could only read the hashes
of passwords. He can't use the hash to log in, and he can't deduce the password
from the hash value because the hash function has the property of pre-image
resistance.
Data
Integrity Check: The most general use of hash
functions is to verify data integrity. Checksums on data files are generated
with it. This application gives the user assurance that the data is correct.
The integrity check aids the user in detecting any modifications to the
original file. It does not, however, guarantee that the work is unique. Instead
of changing file data, the hacker can change the entire file and compute a new
hash before sending it to the recipient. This integrity testing tool is only
helpful if the user is certain of the file's uniqueness.
Encryption
vs Hashing:
Encryption is a two-way function where, using an encryption key, information is encrypted and then decoded using a decryption key. The information is encrypted in a way that it can be read-only by approved parties. It is used to discourage unauthorized users from accessing a file’s data by making it unreadable.
0 Comments
if you have any doubts plz let me know...