]>
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 | ||
16 | #ifdef __GNUG__ | |
678bc33e | 17 | #pragma interface "apt-pkg/hashes.h" |
63b1700f AL |
18 | #endif |
19 | ||
20 | #include <apt-pkg/md5.h> | |
21 | #include <apt-pkg/sha1.h> | |
22 | ||
8bdbcf67 MZ |
23 | #include <algorithm> |
24 | ||
25 | using std::min; | |
26 | ||
63b1700f AL |
27 | class Hashes |
28 | { | |
29 | public: | |
30 | ||
31 | MD5Summation MD5; | |
32 | SHA1Summation SHA1; | |
33 | ||
34 | inline bool Add(const unsigned char *Data,unsigned long Size) | |
35 | { | |
678bc33e | 36 | return MD5.Add(Data,Size) && SHA1.Add(Data,Size); |
63b1700f AL |
37 | }; |
38 | inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));}; | |
39 | bool AddFD(int Fd,unsigned long Size); | |
40 | inline bool Add(const unsigned char *Beg,const unsigned char *End) | |
41 | {return Add(Beg,End-Beg);}; | |
42 | }; | |
43 | ||
44 | #endif |