# The Differences Between Hashing and Encryption

Since **hash functions** are a type of **cryptographic primitive** (building blocks used in security systems), they are often confused with **encryption**. But the two serve **different purposes**.

Here are the three key differences:

***

#### 1. Data Preservation vs. Data Loss

* **Hashing:** Produces a **fixed-length output** in clear text. It acts as a **digital fingerprint** of the input, and **data loss is not a concern**.
* **Encryption:** Encodes and **preserves the entire message**, so it can later be **decrypted** back into its original form.

👉 **Key takeaway:** Hashing is about **verification**, encryption is about **confidentiality**.

***

#### 2. Reversibility

* **Hashing:** A **one-way function**. It is **not reversible** — and that’s what makes it secure.
* **Encryption:** Must be **reversible**. The intended recipient needs to **decrypt** the message to read it.

👉 **Key takeaway:** Hashes stay one-way, encrypted data must come back.

***

#### 3. Collision Risk

* **Hashing:** Because outputs are **fixed length**, two different inputs can, in theory, produce the **same hash** — this is called a **collision**.
  * In practice, BSV uses **SHA-256** and **RIPEMD-160**, which make collisions **extremely rare** (probabilistically insignificant).
* **Encryption:** Since it **preserves 100% of the input**, each encrypted message produces a **unique output** — meaning **no collision risk**.

👉 **Key takeaway:** Hashes can collide (though rarely), encrypted data cannot.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hub.bsvblockchain.org/higher-learning/bsv-academy/bitcoin-primitives-hash-functions/what-are-hash-functions/the-differences-between-hashing-and-encryption.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
