# The Difference Between Hashing and Encryption

<figure><img src="/files/pwCQufb5OKVMF5ISW1OK" alt=""><figcaption></figcaption></figure>

Since hash functions are a type of cryptographic primitive -- i.e., some of the building blocks used to encrypt messages and data -- the **concepts of hashing and encryption are often conflated**. However, they are not the same. The three main differences between hashing and encryption are as follows:

1. **Hash functions don't care about data loss:**\
   \
   A hash function produces a fixed-length output in clear text because it’s nothing more than a unique digital fingerprint and data loss is not a concern. **In contrast,** encryption encodes and preserves input messages.<br>
2. **Hash functions are not reversible:**\
   \
   A hash function is a one-way function that does not need to be reversed. In fact, it's important it's not reversible. **In contrast**, it's crucial the intended recipient of an encrypted message is able to reverse the encryption process in order to decrypt the message so they can read it.<br>
3. **Hash functions have a collision risk:**\
   \
   A hash function has a collision risk. Due to the fixed length of message digests, it's possible for two different input values to produce the same digest. Bitcoin uses hash functions like SHA-256 and RIPEMD-160 because they greatly reduce the risk of collisions, yet, although they're probabilistically insignificant, they can still theoretically happen.\
   \
   **In contrast,** since encryption preserves 100% of the input message, each encrypted message produces a unique output so there's no collision risk.


---

# 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/hash-functions-crash-course/the-difference-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.
