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
9namespace hgps {
10
15std::string compute_sha256_for_file(const std::filesystem::path &file_path,
16 size_t buffer_size = static_cast<size_t>(1024 * 1024));
17
20 public:
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
An object for computing a SHA256 hash.
Definition sha256.h:19
void update(const R &range)
Feed in more data to the hash algorithm.
Definition sha256.h:27
~SHA256Context()
Definition sha256.cpp:39
std::string finalise()
Finish calculating the hash and return.
Definition sha256.cpp:41
SHA256Context()
Definition sha256.cpp:35
Top-level namespace for Health-GPS Console host application.
Definition command_options.cpp:8
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