10Duke Scale C++ Client
Loading...
Searching...
No Matches
MessageDigest.h
1#ifndef TENDUKE_CRYPTO_MESSAGEDIGEST_H
2#define TENDUKE_CRYPTO_MESSAGEDIGEST_H
3
4#include "utl/BinaryData.h"
5#include <cstddef>
6#include <memory>
7#include <string>
8
9namespace tenduke { namespace crypto {
10
12const std::size_t SHA256_HASH_LENGTH_BYTES = 32;
13
21{
22public:
24 enum Algorithm {
25 NONE,
26 SHA256
27 };
28
29public:
30 virtual ~MessageDigest() = default;
31
36 virtual std::size_t length() const = 0;
37
46 const unsigned char * message,
47 std::size_t messageLength
48 ) = 0;
49
55 virtual void digestTo(unsigned char * messageDigest) = 0;
56
62 virtual std::unique_ptr<tenduke::utl::BinaryData> digest() = 0;
63
69 static std::string algorithmToString(enum MessageDigest::Algorithm algorithm);
70
76 static enum MessageDigest::Algorithm stringToAlgorithm(const std::string &string);
77
83 static enum MessageDigest::Algorithm stringToAlgorithm(const char * string);
84};
85
86
87}}
88
89#endif // TENDUKE_CRYPTO_MESSAGEDIGEST_H
Simple MessageDigest -service.
Definition MessageDigest.h:21
virtual MessageDigest * update(const unsigned char *message, std::size_t messageLength)=0
Updates the digest.
static enum MessageDigest::Algorithm stringToAlgorithm(const std::string &string)
Converts string to algorithm.
Definition MessageDigest.cpp:15
virtual std::unique_ptr< tenduke::utl::BinaryData > digest()=0
Computes the digest.
virtual std::size_t length() const =0
Returns length (in bytes) of the resulting digest.
static std::string algorithmToString(enum MessageDigest::Algorithm algorithm)
Converts algorithm to string representation.
Definition MessageDigest.cpp:5
virtual void digestTo(unsigned char *messageDigest)=0
Computes the digest to pre-allocated buffer.
Algorithm
Supported algorithms.
Definition MessageDigest.h:24
Cryptography services.
Definition CryptoException.h:7
const std::size_t SHA256_HASH_LENGTH_BYTES
Length of SHA256 hash binary representation in bytes.
Definition MessageDigest.h:12
Root for classes, functions and globals of 10Duke C++ Client.
Definition BackendConfiguration.h:7