Digest.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00015 #ifndef ZYPP_MEDIA_DIGEST_H
00016 #define ZYPP_MEDIA_DIGEST_H
00017 
00018 #include <string>
00019 #include <iosfwd>
00020 
00021 #include <zypp/Callback.h>
00022 #include <zypp/Pathname.h>
00023 
00024 namespace zypp {
00025 
00026 
00027   struct DigestReport : public callback::ReportBase
00028   {
00029     virtual bool askUserToAcceptNoDigest( const zypp::Pathname &file );
00030     virtual bool askUserToAccepUnknownDigest( const Pathname &file, const std::string &name );
00031     virtual bool askUserToAcceptWrongDigest( const Pathname &file, const std::string &requested, const std::string &found );
00032   };
00033 
00034 
00035 
00044     class Digest
00045     {
00046       private:
00047         class P;
00048         P* _dp;
00049 
00050         // disabled
00051         Digest(const Digest& d);
00052         // disabled
00053         const Digest& operator=(const Digest& d);
00054 
00055       public:
00059         static const std::string & md5();
00061         static const std::string & sha1();
00063         static const std::string & sha256();
00065 
00066       public:
00067         Digest();
00068         ~Digest();
00069 
00083         bool create(const std::string& name);
00084 
00086         const std::string& name();
00087 
00093         bool update(const char* bytes, size_t len);
00094 
00102         std::string digest();
00103 
00114         static std::string digest(const std::string& name, std::istream& is, size_t bufsize = 4096);
00115 
00117         static std::string digest( const std::string & name, const std::string & input, size_t bufsize = 4096 );
00118     };
00119 
00120 } // namespace zypp
00121 
00122 #endif

doxygen