libzypp  17.28.8
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 
25 namespace zypp {
26 
35  class Digest
36  {
37  private:
38  class P;
39  P* _dp;
40 
41  // disabled
42  Digest(const Digest& d);
43  // disabled
44  const Digest& operator=(const Digest& d);
45 
46  public:
50  static const std::string & md5();
52  static const std::string & sha1();
54  static const std::string & sha224();
56  static const std::string & sha256();
58  static const std::string & sha384();
60  static const std::string & sha512();
62 
63  public:
64  Digest();
65  ~Digest();
66 
80  bool create(const std::string& name);
81 
83  const std::string& name();
84 
90  bool update(const char* bytes, size_t len);
91 
97  bool update(std::istream& is, size_t bufsize = 4096);
98 
106  std::string digest();
107 
112  static std::string digestVectorToString ( const UByteArray &vec );
113 
114 #ifdef __cpp_lib_string_view
119  static ByteArray hexStringToByteArray ( std::string_view str );
120  static UByteArray hexStringToUByteArray ( std::string_view str );
121 #endif
122 
131 
137  bool reset();
138 
149  static std::string digest(const std::string& name, std::istream& is, size_t bufsize = 4096);
150 
152  static std::string digest( const std::string & name, const std::string & input, size_t bufsize = 4096 );
153  };
154 
155 } // namespace zypp
156 
157 #endif
Compute Message Digests (MD5, SHA1 etc)
Definition: Digest.h:36
static const std::string & md5()
md5
Definition: Digest.cc:32
static const std::string & sha384()
sha384
Definition: Digest.cc:44
std::string digest()
get hex string representation of the digest
Definition: Digest.cc:175
static const std::string & sha512()
sha512
Definition: Digest.cc:47
UByteArray digestVector()
get vector of unsigned char representation of the digest
Definition: Digest.cc:230
static const std::string & sha1()
sha1
Definition: Digest.cc:35
bool update(const char *bytes, size_t len)
feed data into digest computation algorithm
Definition: Digest.cc:248
static const std::string & sha256()
sha256
Definition: Digest.cc:41
static const std::string & sha224()
sha224
Definition: Digest.cc:38
const Digest & operator=(const Digest &d)
static std::string digestVectorToString(const UByteArray &vec)
get hex string representation of the digest vector given as parameter
Definition: Digest.cc:180
Digest(const Digest &d)
bool reset()
reset internal digest state
Definition: Digest.cc:160
const std::string & name()
get the name of the current digest algorithm
Definition: Digest.cc:155
P * _dp
Definition: Digest.h:38
bool create(const std::string &name)
initialize creation of a new message digest
Definition: Digest.cc:143
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2