aboutsummaryrefslogtreecommitdiff
path: root/bpkg/checksum.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-10-20 05:20:03 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-10-22 14:14:40 +0300
commit2fe7c710b13a0cd429b800fe5e147414c6c63596 (patch)
treea8fdb9f1ce281330846f6db230baf977aeab3381 /bpkg/checksum.hxx
parent3105c27bd7d42ee55c55650f83c7fc3483188b82 (diff)
Make use of butl::sha256 class
Diffstat (limited to 'bpkg/checksum.hxx')
-rw-r--r--bpkg/checksum.hxx18
1 files changed, 12 insertions, 6 deletions
diff --git a/bpkg/checksum.hxx b/bpkg/checksum.hxx
index ec5a82e..2342250 100644
--- a/bpkg/checksum.hxx
+++ b/bpkg/checksum.hxx
@@ -5,6 +5,8 @@
#ifndef BPKG_CHECKSUM_HXX
#define BPKG_CHECKSUM_HXX
+#include <libbutl/sha256.mxx>
+
#include <bpkg/types.hxx>
#include <bpkg/utility.hxx>
@@ -12,18 +14,22 @@
namespace bpkg
{
- // Calculate SHA256 sum of the specified memory buffer in binary mode. Issue
- // diagnostics and throw failed if anything goes wrong.
+ // Calculate SHA256 sum of the specified memory buffer in binary mode.
//
- string
- sha256 (const common_options&, const char* buf, size_t n);
+ inline string
+ sha256 (const char* buf, size_t n) {return butl::sha256 (buf, n).string ();}
// The same but for a stream (if ifdstream, open in binary mode).
//
string
- sha256 (const common_options&, istream&);
+ sha256 (istream&);
- // The same but for a file.
+ // The same but for a file. Issue diagnostics and throw failed if anything
+ // goes wrong.
+ //
+ // Note that unlike the other overloads, this function runs the sha256
+ // program underneath. The reason for this is that the program can be
+ // optimized for the platform.
//
string
sha256 (const common_options&, const path& file);