]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/compute/include/boost/compute/detail/sha1.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / detail / sha1.hpp
CommitLineData
7c673cae
FG
1//---------------------------------------------------------------------------//
2// Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
3//
4// Distributed under the Boost Software License, Version 1.0
5// See accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt
7//
8// See http://boostorg.github.com/compute for more information.
9//---------------------------------------------------------------------------//
10
11#ifndef BOOST_COMPUTE_DETAIL_SHA1_HPP
12#define BOOST_COMPUTE_DETAIL_SHA1_HPP
13
14#include <sstream>
15#include <iomanip>
16#include <boost/uuid/sha1.hpp>
17
18namespace boost {
19namespace compute {
20namespace detail {
21
22// Accumulates SHA1 hash of the passed strings.
23class sha1 {
24 public:
25 sha1(const std::string &s = "") {
26 if (!s.empty()) this->process(s);
27 }
28
29 sha1& process(const std::string &s) {
30 h.process_bytes(s.c_str(), s.size());
31 return *this;
32 }
33
34 operator std::string() {
35 unsigned int digest[5];
36 h.get_digest(digest);
37
38 std::ostringstream buf;
39 for(int i = 0; i < 5; ++i)
40 buf << std::hex << std::setfill('0') << std::setw(8) << digest[i];
41
42 return buf.str();
43 }
44 private:
45 boost::uuids::detail::sha1 h;
46};
47
48} // end detail namespace
49} // end compute namespace
50} // end boost namespace
51
52
53#endif // BOOST_COMPUTE_DETAIL_SHA1_HPP