hashes.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #include <apt-pkg/md5.h>
  13. #include <apt-pkg/sha1.h>
  14. #include <apt-pkg/sha256.h>
  15. #include <algorithm>
  16. using std::min;
  17. class Hashes
  18. {
  19. public:
  20. MD5Summation MD5;
  21. SHA1Summation SHA1;
  22. SHA256Summation SHA256;
  23. inline bool Add(const unsigned char *Data,unsigned long Size)
  24. {
  25. return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size);
  26. };
  27. inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));};
  28. bool AddFD(int Fd,unsigned long Size);
  29. inline bool Add(const unsigned char *Beg,const unsigned char *End)
  30. {return Add(Beg,End-Beg);};
  31. };
  32. #endif