How to Install xxHash for faster hash check in Ubuntu

Last updated: January 1, 2024 — Leave a comment

This simple tutorial shows how to install the most recent xxHash for faster hash checking in Ubuntu Linux.

xxHash is extremely fast non-cryptographic hash algorithm, working at RAM speed limit. It can be useful to check integrity for large amounts of data, index data, and/or used in cryptographic applications like digital signatures.

The library includes the following algorithms:

  • XXH32 : generates 32-bit hashes.
  • XXH64 : generates 64-bit hashes.
  • XXH3/XXH128 (since v0.8.0): generates 64 or 128-bit hashes, using vectorized arithmetic.

I’m new to hash algorithm, but doing hash check regularly when trying out different Linux distributions. And I use sha256, since the most sites provide sha256sum files for the hash code of their disco images.

It’s OK for me to run sha256sum for file in SSD, which takes around 20 seconds to print hash code for a 4 GB iso image. But after moving to USB stick (to boot via Ventoy), and hashing again it can take up to 2 minutes!

I was feeling stupid, until met xxHash. Hash checking can be so fast!

For advanced users, see the benchmarks (system uses an Intel i7-9700K cpu, and runs Ubuntu x64 20.04).

Hash Name Width Bandwidth (GB/s) Small Data Velocity Quality Comment
XXH3 (SSE2) 64 31.5 GB/s 133.1 10
XXH128 (SSE2) 128 29.6 GB/s 118.1 10
memcpy N/A 28.0 GB/s N/A N/A for reference
City64 64 22.0 GB/s 76.6 10
T1ha2 64 22.0 GB/s 99.0 9 Slightly worse collisions
City128 128 21.7 GB/s 57.7 10
XXH64 64 19.4 GB/s 71.0 10
SpookyHash 64 19.3 GB/s 53.2 10
Mum 64 18.0 GB/s 67.0 9 Slightly worse collisions
XXH32 32 9.7 GB/s 71.9 10
City32 32 9.1 GB/s 66.0 10
Murmur3 32 3.9 GB/s 56.1 10
SipHash 64 3.0 GB/s 43.2 10
FNV64 64 1.2 GB/s 62.7 5 Poor avalanche properties
Blake2 256 1.1 GB/s 5.1 10 Cryptographic
SHA1 160 0.8 GB/s 5.6 10 Cryptographic but broken
MD5 128 0.6 GB/s 7.8 10 Cryptographic but broken

How to Install xxHash in Ubuntu

xxHash is available in Ubuntu repository, but is (or will be) old since the software keeps moving with newer releases.

To install xxHash from system repository, open terminal (Ctrl+Alt+T) and run command:

sudo apt install xxhash

For the latest version (so far v0.8.2), there are some third-party PPA repositories. And, I use the one from Adam Reviczky, which so far supports Ubuntu 20.04, Ubuntu 22.04, Ubuntu 23.04, and Ubuntu 23.10

  • First, press Ctrl+Alt+T on keyboard to open terminal. When it opens, run command to add the PPA:
    sudo add-apt-repository ppa:reviczky/xxhash

    Type user password when it asks (no asterisk feedback) for sudo authentication. Then, hit Enter to continue.

  • Then, either launch Software Updater to upgrade the tool from version installed from system repository. Or, run command :
    sudo apt install xxhash

    For Linux Mint, run sudo apt update first to refresh system package cache.

After installing the tool, use one of xxh128sum, xxh32sum, xxh64sum, xxhsum commands to do hash checks.

Uninstall xxHash

To uninstall xxHash, open terminal (Ctrl+Alt+T) and run command:

sudo apt remove --autoremove xxhash

Also remove the PPA (if added), by either “Software & Updates” under “Other Software” tab, or running command:

sudo add-apt-repository --remove ppa:reviczky/xxhash

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via [email protected] Buy me a coffee: https://ko-fi.com/ubuntuhandbook1 |

No Comments

Be the first to start the conversation.

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

*