# Hash Functions

<figure><img src="/files/7WzBipxGHqyCyVpQ5Vld" alt=""><figcaption></figcaption></figure>

A hash function is a mathematical process that maps a **bitstring** of any length to a bitstring of a defined length. This process must also be easy to compute. A *one-way hash function* must be **preimage resistant** and **second preimage** **resistant** while a *secure cryptographic* or *ideal hash function* must be preimage resistant, second preimage resistant, and **collision resistant** – we'll cover what these terms mean in the following lessons of this chapter. The hash functions we'll be looking at in this course are the secure ideal hash functions found in the Bitcoin system: **SHA-256** and **RIPEMD-160**. For the remainder of this course, when you see the term *hash function*, it means *secure cryptographic* or *ideal hash function*.

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.

As a result of their unique properties, hash functions are a very important tool in many areas of information technology:

* Hash Tables
* Digital signatures
* Keyed hashes
* One-way transformations
* 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. Since message digests are digital fingerprints, they are very useful for making sure data hasn’t been tampered with.


---

# 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/hash-functions.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.
