> For the complete documentation index, see [llms.txt](https://hub.bsvblockchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hub.bsvblockchain.org/higher-learning/bsv-academy/hash-functions-crash-course/the-difference-between-hashing-and-encryption.md).

# The Difference Between Hashing and Encryption

<figure><img src="https://3421145409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRTEKu4E7Fvtss3GI9CYU%2Fuploads%2FRkEtvOxQJyJ7rP9HfIlV%2Fencrypt.gif?alt=media&amp;token=b7ed2068-3d15-4223-91ad-957dc7764657" 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://hub.bsvblockchain.org/higher-learning/bsv-academy/hash-functions-crash-course/the-difference-between-hashing-and-encryption.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
