DEV Community

chandra penugonda
chandra penugonda

Posted on

Cryptographic Hash Functions

A hash function is a function which takes an input of any size and turns it into a fixed size output.

Let's imagine a hash function that takes an input of any size and returns a fixed 32 byte output:

32 bytes

These inputs get larger from top to bottom but they always map to an output of 32 bytes. There are many different algorithms for hash functions which could take these inputs and create outputs of fixed sizes.

The specific types of hash functions we are going to focus on are cryptographic hash functions. These hash functions need five specific properties. They must be:

🔮 Deterministic - One specific input always maps to the same specific output
🎲 Pseudorandom - It is not possible to guess the output based on the output of similar inputs
➡️ One-way - If someone gives you a new output, you could not determine an input without guessing
🏎️ Fast to Compute - It must be a quick calculation for a computer
💥 Collision-resistant - The chance of a collision should be infinitesimally small

Challenge Yourself: Try using this sha256 online tool. Can you prove to yourself each one of these properties?

source: Alchemy university

Top comments (0)