<p>A checksum is an application of a hash function.</p>

<p>From <a href="https://en.wikipedia.org/wiki/Cryptographic_hash_function" rel="nofollow noreferrer">wikipedia - cryptographic hash function:</a></p>

<blockquote>
  <p>A cryptographic hash... is a mathematical algorithm that maps data of arbitrary size to a bit string of a fixed size (a hash) and is designed to be a one-way function, that is, a function which is infeasible to invert.</p>
</blockquote>

<p>From <a href="https://en.wikipedia.org/wiki/Checksum" rel="nofollow noreferrer">wikipedia - checksum:</a></p>

<blockquote>
  <p>A checksum is a small-sized datum derived from a block of digital data for the purpose of detecting errors which may have been introduced during its transmission or storage.</p>
</blockquote>

<p>As an example of how hash functions and checksums are applied in bitcoin, consider how a bitcoin address is generated from a public key (<a href="https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses" rel="nofollow noreferrer">for full details see this link</a>):</p>

<ul>
<li><p>By employing a hash function, the user's public key remains unknown until an address is spent from, so this keeps a user's funds safe in the case ECDSA is broken (<a href="https://bitcoin.stackexchange.com/questions/3600/why-are-bitcoin-addresses-hashes-of-public-keys">see this question for further reasoning</a>). </p></li>
<li><p>Adding a checksum to the address ensures that a user will not lose coins due to a simple keying/copying error when submitting payments.</p></li>
</ul>

<p>So, we can see that using a hash function allows the user to hide their public key (but easily confirm the address once we know the public key), while also retaining enough bytes in the address to ensure a very large address space. </p>

<p>In contrast, the checksum is short (4 bytes), so obviously we could not use a checksum as the address (the address space would be far too tiny!). But a checksum works well to ensure the address is legitimate, the chance of making a keying error and still having a valid checksum is incredibly small- it is basically impossible in practise! Using the entire hash output as the checksum would work as well, but it would be overkill, and an inefficient use of space (instead of an extra 4 bytes, the address would basically double in size). </p>

CC BY-SA 4.0
2018-09-23T11:32:12.830Z
In general, can we say that all hash algorithms cannot be used as a checksum? meaning that only some specific hash algorithms are eligible to be used as checksum? Thanks
Questioner
CC BY-SA 4.0
2018-09-23T11:41:03.660Z
There are many types of hash functions, choosing the correct one for a certain application is important. Not all hash functions will be appropriate to use in creating a checksum. See https://en.wikipedia.org/wiki/Hash_function#Hash_function_algorithms
chytrik
CC BY-SA 4.0
2018-09-23T12:34:38.107Z
This answer (https://bitcoin.stackexchange.com/a/3602/41513) says that use of hash of public key as an address is only to get **shorter addresses** and there no security or privacy reason. Unlike you who believe it allows the user to **hide** their public key, meaning that there is a security and privacy reason. So don't you agree with that answer about the reason of using hash of public key as an address? Thanks
Questioner
CC BY-SA 4.0
2018-09-23T17:31:29.903Z
@sas read the second paragraph of that answer, and the comments, both of which mention a security aspect. Shortening the payable address is another reason for employing a hash that I didn’t explicitly mention, but instead linked to other answers as supplemental material. In general there may be many advantages to using a certain hash function, not just one single reason.
chytrik
CC BY-SA 4.0
2018-09-23T11:19:58.800Z
2018-09-23T11:19:58.800Z
chytrik
<p>Sometimes these terms are used more or less interchangeably.  Traditionally, a checksum is used to detect corruption and a hash is used to map large elements into slots randomly.  In Bitcoin-land we're often concerned with "cryptographic hashes"  which are hashes that have special security properties.</p>

<p>Things called checksums are usually designed to have certain uniformity properties that make them maximally likely to detect errors.  Things called hashes are usually designed to be very fast to compute and not be too non-uniform.  Things called cryptographic hashes are designed to make it difficult to compute a collision.</p>

<p>The security properties of cryptographic hashes often make them slower and less uniform than functions you would use for cases where the security isn't required.</p>

<p>Generally any function from any of the three groups could be used in any of the applications, the result would just not achieve the security, performance, or reliability that you'd get for using the right tool for the job.</p>

CC BY-SA 4.0
2018-09-23T19:02:04.860Z
2018-09-24T17:52:23.140Z
2018-09-24T17:52:23.140Z
G. Maxwell
<p>What are <strong>similarities</strong> and <strong>differences</strong> between a <strong>"checksum"</strong> algorithm and a <strong>"hash"</strong> function? </p>

<p>Can they be used instead of each other? Or their usage are different?</p>

<p>For example, for verifying the integrity of a text, which one is better to be used?</p>

CC BY-SA 4.0
2022-08-04T02:58:38.040Z
Cross-posted: https://security.stackexchange.com/q/194600/971, https://bitcoin.stackexchange.com/q/79511/14915, https://ethereum.stackexchange.com/q/59275/19041.  Please [do not post the same question on multiple sites](https://meta.stackexchange.com/q/64068).
D.W.
<hash><checksum>
Checksum vs. Hash: Differences and Similarities ?
Questioner
# Checksum vs. Hash: Differences and Similarities ?

(Asked by: username_0 on 2018-09-23)

What are **similarities** and **differences** between a **"checksum"** algorithm and a **"hash"** function?

Can they be used instead of each other? Or their usage are different?

For example, for verifying the integrity of a text, which one is better to be used?

**Tags:** hash, checksum

> **Comments:**
> **username_1**: Cross-posted: https://security.stackexchange.com/q/194600/971, https://bitcoin.stackexchange.com/q/79511/14915, https://ethereum.stackexchange.com/q/59275/19041.  Please [do not post the same question on multiple sites](https://meta.stackexchange.com/q/64068).  

---

## 2 answers

### Answer by username_2 on 2018-09-23. Score: 2 | Accepted answer

A checksum is an application of a hash function.

From [wikipedia - cryptographic hash function:](https://en.wikipedia.org/wiki/Cryptographic_hash_function)

> A cryptographic hash... is a mathematical algorithm that maps data of arbitrary size to a bit string of a fixed size (a hash) and is designed to be a one-way function, that is, a function which is infeasible to invert.

From [wikipedia - checksum:](https://en.wikipedia.org/wiki/Checksum)

> A checksum is a small-sized datum derived from a block of digital data for the purpose of detecting errors which may have been introduced during its transmission or storage.

As an example of how hash functions and checksums are applied in bitcoin, consider how a bitcoin address is generated from a public key ([for full details see this link](https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses)):

* By employing a hash function, the user's public key remains unknown until an address is spent from, so this keeps a user's funds safe in the case ECDSA is broken ([see this question for further reasoning](https://bitcoin.stackexchange.com/questions/3600/why-are-bitcoin-addresses-hashes-of-public-keys)).
* Adding a checksum to the address ensures that a user will not lose coins due to a simple keying/copying error when submitting payments.

So, we can see that using a hash function allows the user to hide their public key (but easily confirm the address once we know the public key), while also retaining enough bytes in the address to ensure a very large address space.

In contrast, the checksum is short (4 bytes), so obviously we could not use a checksum as the address (the address space would be far too tiny!). But a checksum works well to ensure the address is legitimate, the chance of making a keying error and still having a valid checksum is incredibly small- it is basically impossible in practise! Using the entire hash output as the checksum would work as well, but it would be overkill, and an inefficient use of space (instead of an extra 4 bytes, the address would basically double in size).

> **Comments:**
> **username_0**: In general, can we say that all hash algorithms cannot be used as a checksum? meaning that only some specific hash algorithms are eligible to be used as checksum? Thanks  
> **username_2**: There are many types of hash functions, choosing the correct one for a certain application is important. Not all hash functions will be appropriate to use in creating a checksum. See https://en.wikipedia.org/wiki/Hash_function#Hash_function_algorithms  
> **username_0**: This answer (https://bitcoin.stackexchange.com/a/3602/41513) says that use of hash of public key as an address is only to get **shorter addresses** and there no security or privacy reason. Unlike you who believe it allows the user to **hide** their public key, meaning that there is a security and privacy reason. So don't you agree with that answer about the reason of using hash of public key as an address? Thanks  
> **username_2**: @sas read the second paragraph of that answer, and the comments, both of which mention a security aspect. Shortening the payable address is another reason for employing a hash that I didn’t explicitly mention, but instead linked to other answers as supplemental material. In general there may be many advantages to using a certain hash function, not just one single reason.  

---

### Answer by username_3 on 2018-09-23. Score: 4

Sometimes these terms are used more or less interchangeably. Traditionally, a checksum is used to detect corruption and a hash is used to map large elements into slots randomly. In Bitcoin-land we're often concerned with "cryptographic hashes" which are hashes that have special security properties.

Things called checksums are usually designed to have certain uniformity properties that make them maximally likely to detect errors. Things called hashes are usually designed to be very fast to compute and not be too non-uniform. Things called cryptographic hashes are designed to make it difficult to compute a collision.

The security properties of cryptographic hashes often make them slower and less uniform than functions you would use for cases where the security isn't required.

Generally any function from any of the three groups could be used in any of the applications, the result would just not achieve the security, performance, or reliability that you'd get for using the right tool for the job.


---

