Different uses of hashing

🧠 PART 1 β€” WHAT IS HASHING? (FROM ZERO)

πŸ’‘ Start with a problem

Imagine you store a password:

mypassword123

If someone hacks the system:

πŸ‘‰ They can see the password 😬


πŸ” Solution: Hashing

Instead of storing the password, we store a hash


πŸ’‘ What is a hash?

πŸ‘‰ A hash is the output of a function that turns data into a fixed-length string.

Example:

mypassword123 β†’ 9f86d081884c7d65

πŸ‘‰ That output = hash value


⚠ Important properties (YOU MUST KNOW)

  1. One-way


    • You cannot reverse it easily


    • You can’t get the original data back

  2. Same input β†’ same output


    • Always consistent

  3. Small change β†’ completely different hash

Example:

password β†’ 5f4dcc3b5aa  
Password β†’ 7c6a180b368

πŸ”₯ KEY IDEA

πŸ‘‰ Hashing is NOT encryption

πŸ‘‰ You cannot decrypt a hash


🧠 PART 2 β€” USES OF HASHING (WHAT OCR CARES ABOUT)


πŸ”΅ 1. Password Storage

πŸ’‘ How it works


  1. User creates password


  2. System hashes it


  3. Hash is stored (NOT the password)


πŸ”„ Login process


  1. User enters password


  2. System hashes it again


  3. Compares hashes

βœ” If same β†’ access granted

❌ If different β†’ denied


πŸ” Why this is good

Even if hacked:

πŸ‘‰ attacker only sees hashes, not passwords


πŸ”΄ 2. Data Integrity (Checking data hasn’t changed)

πŸ’‘ Problem

You download a file β€” how do you know it wasn’t changed?


πŸ’‘ Solution


  1. Original file has a hash


  2. You download file


  3. Your computer hashes it


  4. Compare hashes

βœ” Same β†’ file is safe

❌ Different β†’ file has been altered


🟒 3. Digital Signatures (simplified)

Used to verify:


  • sender identity


  • data integrity

πŸ‘‰ Instead of signing the whole file:


  • hash is created


  • hash is signed

Faster and efficient


βš– ADVANTAGES & DISADVANTAGES


βœ… Advantages of Hashing


  • Protects passwords (not stored directly)


  • Fast to compute


  • Ensures data integrity


  • Fixed output size (efficient)


  • One-way (secure)


❌ Disadvantages of Hashing


  • Cannot retrieve original data


  • Vulnerable to brute force attacks (guessing inputs)


  • Possible collisions (two inputs give same hash β€” rare but possible)


  • Needs extra security (e.g. salting β€” not required in depth for OCR)