1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #ifndef BOOST_COMPUTE_DETAIL_SHA1_HPP
- #define BOOST_COMPUTE_DETAIL_SHA1_HPP
- #include <sstream>
- #include <iomanip>
- #include <boost/uuid/sha1.hpp>
- namespace boost {
- namespace compute {
- namespace detail {
- class sha1 {
- public:
- sha1(const std::string &s = "") {
- if (!s.empty()) this->process(s);
- }
- sha1& process(const std::string &s) {
- h.process_bytes(s.c_str(), s.size());
- return *this;
- }
- operator std::string() {
- unsigned int digest[5];
- h.get_digest(digest);
- std::ostringstream buf;
- for(int i = 0; i < 5; ++i)
- buf << std::hex << std::setfill('0') << std::setw(8) << digest[i];
- return buf.str();
- }
- private:
- boost::uuids::detail::sha1 h;
- };
- }
- }
- }
- #endif
|