Compile time SHA-1 hash calculation.
More...
#include <cstdint>
#include <array>
#include <stdexcept>
|
template<bool HasTrailingZero = false, std::uint32_t N> |
constexpr Sha1Status | sha1Process (Sha1State &md, const unsigned char(&in)[N]) |
|
constexpr Sha1Status | sha1Done (Sha1State &md, unsigned char *const out) |
|
template<bool HasTrailingZero = false, std::size_t N> |
constexpr std::array< unsigned char, 20 > | ct_sha1 (const unsigned char(&in)[N]) |
|
Compile time SHA-1 hash calculation.
- Author
- Martin Kraner
- Date
- 04/03/2019
- Version
- 1.0
◆ ct_sha1()
constexpr std::array<unsigned char, 20> ct_sha1 |
( |
const unsigned char(&) |
in[N] | ) |
|
|
constexpr |
Calculates the SHA-1 digest in compile-time if the arguments are constexpr.
- Template Parameters
-
HasTrailingZero | Whether the input data is a null terminated string |
N | The length of the input data array. |
- Parameters
-
in | The input data to hash. |
- Returns
- The 20 bytes representing a Sha1 digest of the input data.
◆ sha1Done()
constexpr Sha1Status Detail::sha1Done |
( |
Sha1State & |
md, |
|
|
unsigned char *const |
out |
|
) |
| |
|
constexpr |
Terminate the hash to get the digest
- Parameters
-
md | The hash state |
out | [out] The destination of the hash (20 bytes) |
- Returns
- Sha1Status::Ok if successful
◆ sha1Process()
constexpr Sha1Status Detail::sha1Process |
( |
Sha1State & |
md, |
|
|
const unsigned char(&) |
in[N] |
|
) |
| |
|
constexpr |
Process a block of memory though the hash
- Template Parameters
-
HasTrailingZero | Whether the input data is a null terminated string |
N | The length of the input data array. |
- Parameters
-
md | The hash state |
in | The data to hash |
- Returns
- Sha1Status::Ok if successful