libzypp  17.14.0
Digest.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
15 #ifndef ZYPP_MEDIA_DIGEST_H
16 #define ZYPP_MEDIA_DIGEST_H
17 
18 #include <string>
19 #include <iosfwd>
20 #include <vector>
21 
22 #include "zypp/Callback.h"
23 #include "zypp/Pathname.h"
24 
25 namespace zypp {
26 
27 
29  {
30  virtual bool askUserToAcceptNoDigest( const zypp::Pathname &file );
31  virtual bool askUserToAccepUnknownDigest( const Pathname &file, const std::string &name );
32  virtual bool askUserToAcceptWrongDigest( const Pathname &file, const std::string &requested, const std::string &found );
33  };
34 
35 
36 
45  class Digest
46  {
47  private:
48  class P;
49  P* _dp;
50 
51  // disabled
52  Digest(const Digest& d);
53  // disabled
54  const Digest& operator=(const Digest& d);
55 
56  public:
60  static const std::string & md5();
62  static const std::string & sha1();
64  static const std::string & sha224();
66  static const std::string & sha256();
68  static const std::string & sha384();
70  static const std::string & sha512();
72 
73  public:
74  Digest();
75  ~Digest();
76 
90  bool create(const std::string& name);
91 
93  const std::string& name();
94 
100  bool update(const char* bytes, size_t len);
101 
109  std::string digest();
110 
118  std::vector<unsigned char> digestVector();
119 
125  bool reset();
126 
137  static std::string digest(const std::string& name, std::istream& is, size_t bufsize = 4096);
138 
140  static std::string digest( const std::string & name, const std::string & input, size_t bufsize = 4096 );
141  };
142 
143 } // namespace zypp
144 
145 #endif
static const std::string & sha256()
sha256
Definition: Digest.cc:53
static const std::string & sha1()
sha1
Definition: Digest.cc:47
std::string digest()
get hex string representation of the digest
Definition: Digest.cc:188
Compute Message Digests (MD5, SHA1 etc)
Definition: Digest.h:45
virtual bool askUserToAccepUnknownDigest(const Pathname &file, const std::string &name)
Definition: Digest.cc:37
const std::string & name()
get the name of the current digest algorithm
Definition: Digest.cc:168
bool reset()
reset internal digest state
Definition: Digest.cc:173
static const std::string & sha512()
sha512
Definition: Digest.cc:59
std::vector< unsigned char > digestVector()
get vector of unsigned char representation of the digest
Definition: Digest.cc:212
const Digest & operator=(const Digest &d)
virtual bool askUserToAcceptNoDigest(const zypp::Pathname &file)
Definition: Digest.cc:34
bool create(const std::string &name)
initialize creation of a new message digest
Definition: Digest.cc:156
static const std::string & md5()
md5
Definition: Digest.cc:44
P * _dp
Definition: Digest.h:48
static const std::string & sha224()
sha224
Definition: Digest.cc:50
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
virtual bool askUserToAcceptWrongDigest(const Pathname &file, const std::string &requested, const std::string &found)
Definition: Digest.cc:40
bool update(const char *bytes, size_t len)
feed data into digest computation algorithm
Definition: Digest.cc:230
static const std::string & sha384()
sha384
Definition: Digest.cc:56