Small, fast, header only, zero dependency cryptographic library written in C++2a.
Cryptographic Hash Functions (CHFs) are a family of algorithms that take an input (or message) and produce a fixed-size output, known as the hash value or digest. This process is a one-way function, meaning it is computationally infeasible to reverse the hash value to obtain the original input. Additionally, small changes in the input will result in significantly different hash values.
| Class | Word bits | Size bits | Block bits | Rounds | State bits | Output bits |
|---|---|---|---|---|---|---|
| MD4 | 32 | 64 | 512 | 3 | 128 | 128 |
| MD5 | 32 | 64 | 512 | 64 | 128 | 128 |
| RMD<128> | 32 | 64 | 512 | 64 | 128 | 128 |
| RMD<160> | 32 | 64 | 512 | 80 | 160 | 160 |
| RMD<256> | 32 | 64 | 512 | 64 | 256 | 256 |
| RMD<320> | 32 | 64 | 512 | 80 | 320 | 320 |
| SHA1 | 32 | 64 | 512 | 80 | 160 | 160 |
| SHA2<256,224> | 32 | 64 | 512 | 64 | 256 | 224 |
| SHA2<256,256> | 32 | 64 | 512 | 64 | 256 | 256 |
| SHA2<512,224> | 64 | 128 | 1024 | 80 | 512 | 224 |
| SHA2<512,256> | 64 | 128 | 1024 | 80 | 512 | 256 |
| SHA2<512,384> | 64 | 128 | 1024 | 80 | 512 | 384 |
| SHA2<512,512> | 64 | 128 | 1024 | 80 | 512 | 512 |
Double hashing the contents of a container holding trivially copyable objects with the help of SHA2<256> and RMD<160>. Note that rmd<160>(message) is an alias for RMD<160>().update(message).digest().
#include <crypto/rmd.h>
#include <crypto/sha2.h>
using namespace crypto;
auto
hash(const auto &trivially_copyable_objects) {
auto hasher = SHA2<256>();
for (const auto &entry: trivially_copyable_objects) {
hasher.update(entry);
}
return rmd<160>(hasher.update("secret").digest());
}Message Authentication Codes (MACs) are cryptographic mechanisms used to ensure the integrity and authenticity of a message or data transmission. They provide a way to verify that a message has not been tampered with during transmission and that it originates from a trusted source.
Only the hash-based message authentication code (HMAC) is supported at the moment.
Double hashing the contents of a container holding trivially copyable objects with the help of HMAC, SHA2<256> and RMD<160>. Note that hmac<RMD<160>>(secret, message) is an alias for HMAC<RMD<160>>(secret).update(message).digest().
#include <crypto/rmd.h>
#include <crypto/sha2.h>
#include <crypto/hmac.h>
using namespace crypto;
auto
hash(const auto &trivially_copyable_objects) {
auto hasher = HMAC<SHA2<256>>("secret 1");
for (const auto &entry: trivially_copyable_objects) {
hasher.update(entry);
}
return hmac<RMD<160>>("secret 2", hasher.digest());
}Download the sources to the folder of choice and include the desired headers.
Feature requests, bug reports and success stories are most welcome.
Copyright 2018 Quasis - The MIT License