1 // -*- mode: cpp; mode: fold -*-
3 // $Id: hashes.h,v 1.2 2001/03/11 05:30:20 jgg Exp $
4 /* ######################################################################
6 Hashes - Simple wrapper around the hash functions
8 This is just used to make building the methods simpler, this is the
9 only interface required..
11 ##################################################################### */
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/sha256.h>
28 // helper class that contains hash function name
35 static const char * _SupportedHashes
[10];
38 HashString(string Type
, string Hash
);
39 HashString(string StringedHashString
); // init from str as "type:hash"
43 string
HashType() { return Type
; };
45 // verify the given filename against the currently loaded hash
46 bool VerifyFile(string filename
) const;
49 string
toStr() const; // convert to str as "type:hash"
52 // return the list of hashes we support
53 static const char** SupportedHashes();
62 SHA256Summation SHA256
;
64 inline bool Add(const unsigned char *Data
,unsigned long Size
)
66 return MD5
.Add(Data
,Size
) && SHA1
.Add(Data
,Size
) && SHA256
.Add(Data
,Size
);
68 inline bool Add(const char *Data
) {return Add((unsigned char *)Data
,strlen(Data
));};
69 bool AddFD(int Fd
,unsigned long Size
);
70 inline bool Add(const unsigned char *Beg
,const unsigned char *End
)
71 {return Add(Beg
,End
-Beg
);};