]>
Commit | Line | Data |
---|---|---|
63b1700f AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
678bc33e | 3 | // $Id: hashes.h,v 1.2 2001/03/11 05:30:20 jgg Exp $ |
63b1700f AL |
4 | /* ###################################################################### |
5 | ||
6 | Hashes - Simple wrapper around the hash functions | |
7 | ||
8 | This is just used to make building the methods simpler, this is the | |
9 | only interface required.. | |
10 | ||
11 | ##################################################################### */ | |
12 | /*}}}*/ | |
13 | #ifndef APTPKG_HASHES_H | |
14 | #define APTPKG_HASHES_H | |
15 | ||
63b1700f AL |
16 | |
17 | #include <apt-pkg/md5.h> | |
18 | #include <apt-pkg/sha1.h> | |
cde41ae8 | 19 | #include <apt-pkg/sha256.h> |
63b1700f | 20 | |
42ab8223 MV |
21 | #include <algorithm> |
22 | ||
23 | using std::min; | |
24 | ||
63b1700f AL |
25 | class Hashes |
26 | { | |
27 | public: | |
28 | ||
29 | MD5Summation MD5; | |
30 | SHA1Summation SHA1; | |
cde41ae8 | 31 | SHA256Summation SHA256; |
63b1700f AL |
32 | |
33 | inline bool Add(const unsigned char *Data,unsigned long Size) | |
34 | { | |
cde41ae8 | 35 | return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size); |
63b1700f AL |
36 | }; |
37 | inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));}; | |
38 | bool AddFD(int Fd,unsigned long Size); | |
39 | inline bool Add(const unsigned char *Beg,const unsigned char *End) | |
40 | {return Add(Beg,End-Beg);}; | |
41 | }; | |
42 | ||
43 | #endif |