13 #ifndef APTPKG_HASHES_H
14 #define APTPKG_HASHES_H
17 #include <apt-pkg/md5.h>
18 #include <apt-pkg/sha1.h>
19 #include <apt-pkg/sha2.h>
20 #include <apt-pkg/fileutl.h>
27 #ifndef APT_8_CLEANER_HEADERS
39 static const char* _SupportedHashes[10];
42 std::string GetHashForFile(std::string filename)
const;
45 HashString(std::string Type, std::string Hash);
50 std::string HashType() {
return Type; };
53 bool VerifyFile(std::string filename)
const;
56 bool FromFile(std::string filename);
60 std::string toStr()
const;
64 static const char** SupportedHashes();
76 inline bool Add(
const unsigned char *Data,
unsigned long long Size)
78 return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size) && SHA512.Add(Data,Size);
80 inline bool Add(
const char *Data) {
return Add((
unsigned char *)Data,strlen(Data));};
81 inline bool AddFD(
int const Fd,
unsigned long long Size = 0)
82 {
return AddFD(Fd, Size,
true,
true,
true,
true); };
83 bool AddFD(
int const Fd,
unsigned long long Size,
bool const addMD5,
84 bool const addSHA1,
bool const addSHA256,
bool const addSHA512);
85 inline bool AddFD(
FileFd &Fd,
unsigned long long Size = 0)
86 {
return AddFD(Fd, Size,
true,
true,
true,
true); };
87 bool AddFD(
FileFd &Fd,
unsigned long long Size,
bool const addMD5,
88 bool const addSHA1,
bool const addSHA256,
bool const addSHA512);
89 inline bool Add(
const unsigned char *Beg,
const unsigned char *End)
90 {
return Add(Beg,End-Beg);};