# Introduction

<figure><img src="/files/UysMrj9ttUc47RvxmOFT" 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: 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/introduction.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.
