blob: 234225047815ed0f662363b026bcc6aa7f958b6b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
// file : bpkg/checksum.hxx -*- C++ -*-
// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
#ifndef BPKG_CHECKSUM_HXX
#define BPKG_CHECKSUM_HXX
#include <libbutl/sha256.mxx>
#include <bpkg/types.hxx>
#include <bpkg/utility.hxx>
#include <bpkg/common-options.hxx>
namespace bpkg
{
// Calculate SHA256 sum of the specified memory buffer in binary mode.
//
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 (istream&);
// 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);
}
#endif // BPKG_CHECKSUM_HXX
|