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

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay