diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-01-24 14:46:19 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-01-30 12:32:32 +0200 |
commit | 67a0e8d70f0caf8b85e0cf2031333236b2a3dcdf (patch) | |
tree | 3a7d71cd1553338cccb19190dc47bfceafd52499 /bpkg/checksum | |
parent | cf86194e91d55464f9c137258e4157415d196697 (diff) |
Add checksum verification
Diffstat (limited to 'bpkg/checksum')
-rw-r--r-- | bpkg/checksum | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/bpkg/checksum b/bpkg/checksum new file mode 100644 index 0000000..3ef35cc --- /dev/null +++ b/bpkg/checksum @@ -0,0 +1,32 @@ +// file : bpkg/checksum -*- C++ -*- +// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BPKG_CHECKSUM +#define BPKG_CHECKSUM + +#include <bpkg/types> +#include <bpkg/utility> + +#include <bpkg/common-options> + +namespace bpkg +{ + // Calculate SHA256 sum of the specified memory buffer in binary mode. Issue + // diagnostics and throw failed if anything goes wrong. + // + string + sha256 (const common_options&, const char* buf, size_t n); + + // The same but for a stream (if ifstream, open in binary mode). + // + string + sha256 (const common_options&, istream&); + + // The same but for a file. + // + string + sha256 (const common_options&, const path& file); +} + +#endif // BPKG_CHECKSUM |