10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
HashAlgorithm.h
1#ifndef TENDUKE_CRYPTO_HASHALGORITHM_H
2#define TENDUKE_CRYPTO_HASHALGORITHM_H
3
4#include <cstdint>
5#include <string>
6
7namespace tenduke { namespace crypto {
8
12enum class HashAlgorithm : std::int16_t
13{
14 UNKNOWN = -1,
15 NONE = 0,
16 SHA256 = 1
17};
18
20constexpr std::size_t SHA256_HASH_LENGTH_BYTES = 32;
21
27inline HashAlgorithm toHashAlgorithm(const std::string &algorithm)
28{
29 if (algorithm == "SHA256") {
30 return HashAlgorithm::SHA256;
31 }
32 if (algorithm == "NONE") {
33 return HashAlgorithm::NONE;
34 }
35 return HashAlgorithm::UNKNOWN;
36}
37
43inline const char * toString(const HashAlgorithm algorithm)
44{
45 switch (algorithm) {
46 case HashAlgorithm::SHA256:
47 return "SHA256";
48 case HashAlgorithm::NONE:
49 return "NONE";
50 default:
51 return "UNKNOWN";
52 }
53}
54
55}}
56
57#endif //TENDUKE_CRYPTO_HASHALGORITHM_H
Cryptography services.
Definition AbstractCiphers.h:18
constexpr std::size_t SHA256_HASH_LENGTH_BYTES
Length of SHA256 hash binary representation in bytes.
Definition HashAlgorithm.h:20
HashAlgorithm
Currently supported hash algorithms.
Definition HashAlgorithm.h:13
const char * toString(const HashAlgorithm algorithm)
Converts HashAlgorithm enum to string representation.
Definition HashAlgorithm.h:43
HashAlgorithm toHashAlgorithm(const std::string &algorithm)
Converts string representation to HashAlgorithm enum.
Definition HashAlgorithm.h:27
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4