hashes.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. class Hashes
  18. {
  19. public:
  20. MD5Summation MD5;
  21. SHA1Summation SHA1;
  22. inline bool Add(const unsigned char *Data,unsigned long Size)
  23. {
  24. return MD5.Add(Data,Size) && SHA1.Add(Data,Size);
  25. };
  26. inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));};
  27. bool AddFD(int Fd,unsigned long Size);
  28. inline bool Add(const unsigned char *Beg,const unsigned char *End)
  29. {return Add(Beg,End-Beg);};
  30. };
  31. #endif