> 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/bitcoin-primitives-hash-functions/what-are-hash-functions/introduction.md).

# Introduction

<figure><img src="https://3421145409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRTEKu4E7Fvtss3GI9CYU%2Fuploads%2FCAJCiRkSAeQb0x6L96Y8%2FHashing%20Algorthim.gif?alt=media&amp;token=79bd62b3-49e3-4ef6-8d5f-a83e1c639b0c" alt=""><figcaption></figcaption></figure>

Hash functions are mathematical functions that take an input (a message, text, file, password, etc.) and output a fixed-size value (the “hash” or “digest”). Cryptographic hash functions are designed with specific security properties to resist attacks.

### Types of hash functions

You can distinguish between a one-way hash function and a secure cryptograp*hic (or ideal)* hash function. A *one-way hash function* must be **preimage resistant** as well as **second preimage** **resistant,** while a ***secure cryptographic*****&#x20;or&#x20;*****ideal hash function*** must fulfil those requirements as well as being **collision resistant.** These topics will be covered in more detail in the following lessons, but simply explained this means:&#x20;

* **Preimage resistant:** Hard to retrieve the input from the hash&#x20;
* **Second preimage resistant:** Hard to retrieve a different input with the same hash
* **Collision resistant:** Hard to find any two inputs with the same hash

The hash functions we'll be looking at in this course are the ones used in BSV: **SHA-256** and **RIPEMD-160**. These are both secure cryptographi / ideal hash functions. Therefore, for the remainder of this course, when you see the term *hash function*, it means *secure cryptographic* or *ideal hash function*.

### Message Digest

The **output values of hash functions are often referred to as message digests, hash values, checksums, or hashes**. We will use these terms interchangeably throughout this course.

You can think of a message digest as analogous to a fingerprint for digital information. In the physical world, a fingerprint is an identifier unique to each individual person such that no two people ever share the same fingerprint. A hash function takes some input message (which can be almost anything as all digital information is essentially a binary string of ones and zeros), and produces a unique, compressed, fixed-length, digital fingerprint for that input message. Since message digests are digital fingerprints, they are very useful for making sure data hasn’t been tampered with.

As a result of their unique properties, hash functions are a very important tool in many areas of information technology, such as Hash Tables, Digital signatures, Keyed hashes, One-way transformations and Key derivation. These operations and techniques form the foundation of most digital storage and communication technologies.

However, the two fundamental uses of hash functions are **maintaining data integrity, and data storage & access efficiency**.&#x20;


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hub.bsvblockchain.org/higher-learning/bsv-academy/bitcoin-primitives-hash-functions/what-are-hash-functions/introduction.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
