Health-GPS
3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
sha256.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <openssl/evp.h>
4
5
#include <algorithm>
6
#include <filesystem>
7
#include <string>
8
9
namespace
hgps
{
10
15
std::string
compute_sha256_for_file
(
const
std::filesystem::path &file_path,
16
size_t
buffer_size =
static_cast<
size_t
>
(1024 * 1024));
17
19
class
SHA256Context
{
20
public
:
21
SHA256Context
();
22
~SHA256Context
();
23
27
template
<
class
R>
void
update
(
const
R &range) {
28
if
(
const
auto
size = std::distance(std::begin(range), std::end(range))) {
29
EVP_DigestUpdate(ctx_, &*std::begin(range), size);
30
}
31
}
32
34
std::string
finalise
();
35
36
private
:
37
EVP_MD_CTX *ctx_;
38
};
39
}
// namespace hgps
hgps::SHA256Context
An object for computing a SHA256 hash.
Definition
sha256.h:19
hgps::SHA256Context::update
void update(const R &range)
Feed in more data to the hash algorithm.
Definition
sha256.h:27
hgps::SHA256Context::~SHA256Context
~SHA256Context()
Definition
sha256.cpp:39
hgps::SHA256Context::finalise
std::string finalise()
Finish calculating the hash and return.
Definition
sha256.cpp:41
hgps::SHA256Context::SHA256Context
SHA256Context()
Definition
sha256.cpp:35
hgps
Top-level namespace for Health-GPS Console host application.
Definition
command_options.cpp:8
hgps::compute_sha256_for_file
std::string compute_sha256_for_file(const std::filesystem::path &file_path, size_t buffer_size)
Compute the SHA256 hash for a file.
Definition
sha256.cpp:13
HealthGPS
sha256.h
Generated by
1.9.8