Hashing
A hashing algorithm is a mathematical function that takes an input (or "message") and returns a fixed-size string of characters, which is typically a hexadecimal number. The output, often called a hash value or hash code, is unique to the specific input data. Hashing algorithms are designed to be one-way functions, meaning that it is computationally infeasible to invert the hash function and obtain the original data from the hash value.
Common hashing algorithms include:
MD5 (Message Digest 5)
SHA-1 (Secure Hash Algorithm 1)
SHA-256, SHA-384, and SHA-512 (part of the SHA-2 family)
bcrypt and scrypt (for secure password storage)
CRC32 (Cyclic Redundancy Check)
Examples
1. HTTPS
HTTPS is a web protocol that uses TLS/SSL to secure communication between a web browser and a web server. TLS/SSL is a cryptographic protocol that is used to secure communication over the internet. TLS/SSL uses hashing algorithms to verify the identity of the server and to protect the integrity of the data being transmitted.

2. SSH
SSH is a secure shell protocol that is used to remotely access a computer. SSH uses hashing algorithms to authenticate users and to encrypt the transmitted data.
3. Git
Git is a distributed version control system that is used to track changes to files and to collaborate on software development projects. Git uses hashing algorithms to identify and store file revisions.
To see the version history of a Git repository, you can use the following command:

This command will list all of the commits that have been made to the repository, in reverse chronological order. Each commit will include the following information:
The commit hash: A unique identifier for the commit
The author and author-date: The person who made the commit and the date and time it was made
The commit message: A short description of the changes that were made in the commit
When you commit changes to a Git repository, Git creates a snapshot of the current state of the repository and calculates a SHA-1 hash for that snapshot. This hash is then used to identify the commit in the repository's history.
4. Blockchain Technology
Blockchain relies on hashing algorithms to secure and verify transactions and blocks. Examples include Bitcoin, Ethereum, and other cryptocurrencies.
Hash algorithms are used in blockchain technology in a number of ways, including:
To create unique identifiers for transactions and blocks: Each transaction and block in a blockchain is assigned a unique hash value. This hash value is calculated using a cryptographic hash function, such as SHA-256. The hash value is then stored in the blockchain, along with the transaction or block itself.
To verify the integrity of transactions and blocks: If a transaction or block is tampered with, its hash value will change. This means that any attempt to tamper with the blockchain will be detected.
To link blocks together: Each block in a blockchain contains the hash value of the previous block. This creates a chain of blocks, which is where the name "blockchain" comes from.
To explore these concepts in more depth, you can refer to the following website for further insights and information.
The main properties of hashing
1. Hashing produces outputs of fixed length
Hashing will always produce a unique, fixed-length output from any input. Let's see what that means with a couple of examples.
Hello World
SHA 256
a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e
Apple
SHA 256
f223faa96f22916294922b171a2696d868fd1f9129302eb41a45b2a2ea2ebbfd
Simplicity is the ultimate sophistication.
SHA 256
0b71a0cd3016e58bb775c949e3759b649aaafc14f1e00e0a0557d2ec78001eec
Three different inputs are hashed using the SHA-256 hash function in the table above.
All three hashes are unique, but their length remains the same. As a result of SHA-256, hashes are 256 bits long, often represented as 64 symbols containing numbers 0-9 and letters A-F.
2. Hashing is deterministic
The same input will always produce the same output. If you use SHA-256 to generate a hash from “batman”, you will always get the output seen in the table below. Even changing one letter, however, will produce a completely different hash.
batman
1532e76dbe9d43d0dea98c331ca5ae8a65c5e8e8b99d3e2a42ae989356f6242a
Batman
bd9b74a682cd757611805f86371a5a277b2941fa42345ce4c87a7c9e28244c2c
3. Hashing is a one-way function
The hashing process is designed to be one-way, meaning it should be computationally infeasible to determine the original input from its hash output.
The only way to determine what the input was is by trying out random strings until you find the right one. This method is known as brute force.
Using brute force to reverse the hash back to the original string is easier said than done. No computer in existence is powerful enough to find the solution in any reasonable amount of time, nor are we ever likely to build one that will. Even IBM Summit, currently the fastest computer in the world, capable of making several trillion calculations per second, would need many years and an astounding amount of electricity to find the answer for a single hash.
4. Hashing is resistant to collisions
A collision occurs when a hashing mechanism produces the same output for two different inputs. This is possible in theory for hashing, as the number of unique hashes is limited but the number of inputs is not.
Resource
Last updated