Digest.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00015 #ifndef ZYPP_MEDIA_DIGEST_H
00016 #define ZYPP_MEDIA_DIGEST_H
00017
00018 #include <string>
00019 #include <iosfwd>
00020 #include <vector>
00021
00022 #include <zypp/Callback.h>
00023 #include <zypp/Pathname.h>
00024
00025 namespace zypp {
00026
00027
00028 struct DigestReport : public callback::ReportBase
00029 {
00030 virtual bool askUserToAcceptNoDigest( const zypp::Pathname &file );
00031 virtual bool askUserToAccepUnknownDigest( const Pathname &file, const std::string &name );
00032 virtual bool askUserToAcceptWrongDigest( const Pathname &file, const std::string &requested, const std::string &found );
00033 };
00034
00035
00036
00045 class Digest
00046 {
00047 private:
00048 class P;
00049 P* _dp;
00050
00051
00052 Digest(const Digest& d);
00053
00054 const Digest& operator=(const Digest& d);
00055
00056 public:
00060 static const std::string & md5();
00062 static const std::string & sha1();
00064 static const std::string & sha256();
00066
00067 public:
00068 Digest();
00069 ~Digest();
00070
00084 bool create(const std::string& name);
00085
00087 const std::string& name();
00088
00094 bool update(const char* bytes, size_t len);
00095
00103 std::string digest();
00104
00112 std::vector<unsigned char> digestVector();
00113
00119 bool reset();
00120
00131 static std::string digest(const std::string& name, std::istream& is, size_t bufsize = 4096);
00132
00134 static std::string digest( const std::string & name, const std::string & input, size_t bufsize = 4096 );
00135 };
00136
00137 }
00138
00139 #endif