hashes.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: hashes.h,v 1.2 2001/03/11 05:30:20 jgg Exp $
  4. /* ######################################################################
  5. Hashes - Simple wrapper around the hash functions
  6. This is just used to make building the methods simpler, this is the
  7. only interface required..
  8. ##################################################################### */
  9. /*}}}*/
  10. #ifndef APTPKG_HASHES_H
  11. #define APTPKG_HASHES_H
  12. #ifdef __GNUG__
  13. #pragma interface "apt-pkg/hashes.h"
  14. #endif
  15. #include <apt-pkg/md5.h>
  16. #include <apt-pkg/sha1.h>
  17. #include <algorithm>
  18. using std::min;
  19. class Hashes
  20. {
  21. public:
  22. MD5Summation MD5;
  23. SHA1Summation SHA1;
  24. inline bool Add(const unsigned char *Data,unsigned long Size)
  25. {
  26. return MD5.Add(Data,Size) && SHA1.Add(Data,Size);
  27. };
  28. inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));};
  29. bool AddFD(int Fd,unsigned long Size);
  30. inline bool Add(const unsigned char *Beg,const unsigned char *End)
  31. {return Add(Beg,End-Beg);};
  32. };
  33. #endif