openDAQ
Open data acquisition platform
sha1.h File Reference

Compile time SHA-1 hash calculation. More...

#include <cstdint>
#include <array>
#include <stdexcept>
+ Include dependency graph for sha1.h:
+ This graph shows which files directly or indirectly include this file:

Functions

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])
 

Detailed Description

Compile time SHA-1 hash calculation.

Author
Martin Kraner
Date
04/03/2019
Version
1.0

Function Documentation

◆ 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
HasTrailingZeroWhether the input data is a null terminated string
NThe length of the input data array.
Parameters
inThe 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
mdThe 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
HasTrailingZeroWhether the input data is a null terminated string
NThe length of the input data array.
Parameters
mdThe hash state
inThe data to hash
Returns
Sha1Status::Ok if successful