# Hashing

Hashing is a way to turn **any data** like a word, password, or a file into a short string of letters and numbers called a **hash**.

It’s like a **digital fingerprint that is** unique, short, and usually impossible to reverse.

So hashing is a one way process that is impossible to reverse.

## Example

If you hash the word :

`hello`

It might turn into something like :

`2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824`

No matter how many times you hash “hello” you will always get the same result no matter what.\
But change even one letter lets say, `Hello` with a capital "H" and the hash is totally different.

### Hashing vs. Encryption

| Feature     | Hashing                      | Encryption               |
| ----------- | ---------------------------- | ------------------------ |
| Reversible? | NO WAYY LOLL                 | yes                      |
| Purpose     | Data integrity and passwords | Privacy and secrecy      |
| Example use | Storing passwords securely   | Sending private messages |

**Hashing is NOT encryption because** you can't "decrypt" a hash because it's not meant to be reversed.

## Why hashing is important

#### 1. **Password Security**

Websites **never store your actual password**.\
Instead they will store the **hash** of your password.

When you log in :

* The site hashes the password you typed
* Then checks if it matches the saved hash

This way even if hackers steal the database they don't get your actual password just the hashes.

> &#x20;Good sites also add something called a **salt** to make hashes stronger and harder to guess.

#### 2. **Checking File Integrity**

When you download a file like a program or update, you can check its **hash**.

If even one bit of the file changes due to corruption or malware the hash will be completely different.

### Hashing Is Not Foolproof

* Some old hashes like MD5 are very weak and can be cracked.
* Hackers can use something called **rainbow tables** (giant lists of hashes) to try to reverse them.
* That’s why we now use stronger hashes like SHA-256 **with salt**.

From this blog you now know how hashes can store your password safely but make sure you keep your passwords hard to reverse because hackers has a giant list of rainbow tables!

\- auric
