libzypp  13.10.6
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 & sha256();
66 
67  public:
68  Digest();
69  ~Digest();
70 
84  bool create(const std::string& name);
85 
87  const std::string& name();
88 
94  bool update(const char* bytes, size_t len);
95 
103  std::string digest();
104 
112  std::vector<unsigned char> digestVector();
113 
119  bool reset();
120 
131  static std::string digest(const std::string& name, std::istream& is, size_t bufsize = 4096);
132 
134  static std::string digest( const std::string & name, const std::string & input, size_t bufsize = 4096 );
135  };
136 
137 } // namespace zypp
138 
139 #endif
static const std::string & sha256()
sha256
Definition: Digest.cc:49
static const std::string & sha1()
sha1
Definition: Digest.cc:46
std::string digest()
get hex string representation of the digest
Definition: Digest.cc:174
Compute Message Digests (MD5, SHA1 etc)
Definition: Digest.h:45
virtual bool askUserToAccepUnknownDigest(const Pathname &file, const std::string &name)
Definition: Digest.cc:36
const std::string & name()
get the name of the current digest algorithm
Definition: Digest.cc:154
bool reset()
reset internal digest state
Definition: Digest.cc:159
std::vector< unsigned char > digestVector()
get vector of unsigned char representation of the digest
Definition: Digest.cc:198
const Digest & operator=(const Digest &d)
virtual bool askUserToAcceptNoDigest(const zypp::Pathname &file)
Definition: Digest.cc:33
bool create(const std::string &name)
initialize creation of a new message digest
Definition: Digest.cc:142
static const std::string & md5()
md5
Definition: Digest.cc:43
P * _dp
Definition: Digest.h:48
virtual bool askUserToAcceptWrongDigest(const Pathname &file, const std::string &requested, const std::string &found)
Definition: Digest.cc:39
bool update(const char *bytes, size_t len)
feed data into digest computation algorithm
Definition: Digest.cc:216