DEV Community

Cover image for hash23 - A constexpr implementation of different hashing algorithms
Rene Windegger
Rene Windegger

Posted on

hash23 - A constexpr implementation of different hashing algorithms

hash23

I've created a constexpr implementation of different hashing algorithms. The library contains a set of non-cryptographic and cryptographic hash functions.

Currently the following algorithms are implemented:

  • CRC32
  • FNV-1
  • FNV-1a
  • MD5
  • SHA2-512

Why it was created

I was looking for a simple way to compute hashes. My first implementation was SHA2-512 because I required a simple API to verify JWT-Tokens in C++23. All implementations I found required a lot of setup and where a pain to use in modern C++.

What makes this library different

  • The library is header only.
  • It has minimal dependencies.
  • It is fully constexpr.
  • It has 100% test coverage.

What is the plan forward

I plan on adding additional hashing algorithms like SHA2-256, SHA3, and Murmur.

Where can I find the library

You can go to GitHub and browse the source code. You can also include it using CPM. Just use something like below.

CPMAddPackage(
    NAME hash23
    GITHUB_REPOSITORY "rwindegger/hash23"
    GIT_TAG "v1.4"
    VERSION 1.4
    OPTIONS
        "BUILD_TESTING OFF"
    EXCLUDE_FROM_ALL YES
)
Enter fullscreen mode Exit fullscreen mode

I look forward to hear back from you with your questions or suggestions. Also don't hesitate to open a GitHub issue with your feature request or improvement proposal.

Top comments (0)