libzypp 17.31.23
Digest.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
15#ifndef ZYPP_CORE_DIGEST_H
16#define ZYPP_CORE_DIGEST_H
17
18#include <string>
19#include <iosfwd>
20#include <vector>
21
22#include <zypp-core/Pathname.h>
23#include <zypp-core/ByteArray.h>
24#include <zypp-core/ByteCount.h>
25
26namespace zypp {
27
36 class Digest
37 {
38 private:
39 class P;
40 P* _dp;
41
42 // disabled
43 Digest(const Digest& d);
44 // disabled
45 const Digest& operator=(const Digest& d);
46
47 public:
51 static const std::string & md5();
53 static const std::string & sha1();
55 static const std::string & sha224();
57 static const std::string & sha256();
59 static const std::string & sha384();
61 static const std::string & sha512();
63
64 public:
65 Digest();
66 ~Digest();
67
81 bool create(const std::string& name);
82
84 const std::string& name();
85
91 bool update(const char* bytes, size_t len);
92
98 bool update(std::istream& is, size_t bufsize = 4096);
99
104
112 std::string digest();
113
118 static std::string digestVectorToString ( const UByteArray &vec );
119
120#ifdef __cpp_lib_string_view
125 static ByteArray hexStringToByteArray ( std::string_view str );
126 static UByteArray hexStringToUByteArray ( std::string_view str );
127#endif
128
136 UByteArray digestVector();
137
143 bool reset();
144
155 static std::string digest(const std::string& name, std::istream& is, size_t bufsize = 4096);
156
158 static std::string digest( const std::string & name, const std::string & input, size_t bufsize = 4096 );
159 };
160
161} // namespace zypp
162
163#endif
Store and operate with byte count.
Definition: ByteCount.h:31
static const std::string & md5()
md5
Definition: Digest.cc:37
static const std::string & sha384()
sha384
Definition: Digest.cc:49
std::string digest()
get hex string representation of the digest
Definition: Digest.cc:206
static const std::string & sha512()
sha512
Definition: Digest.cc:52
UByteArray digestVector()
get vector of unsigned char representation of the digest
Definition: Digest.cc:261
static const std::string & sha1()
sha1
Definition: Digest.cc:40
bool update(const char *bytes, size_t len)
feed data into digest computation algorithm
Definition: Digest.cc:279
zypp::ByteCount bytesHashed() const
Returns the number of input bytes that have been added to the hash.
Definition: Digest.cc:322
const Digest & operator=(const Digest &d)
static const std::string & sha256()
sha256
Definition: Digest.cc:46
static const std::string & sha224()
sha224
Definition: Digest.cc:43
static std::string digestVectorToString(const UByteArray &vec)
get hex string representation of the digest vector given as parameter
Definition: Digest.cc:211
bool reset()
reset internal digest state
Definition: Digest.cc:190
const std::string & name()
get the name of the current digest algorithm
Definition: Digest.cc:185
P * _dp
Definition: Digest.h:40
bool create(const std::string &name)
initialize creation of a new message digest
Definition: Digest.cc:173
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2