libzypp  11.13.5
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