4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
13 #include "support/checksum.h"
21 unsigned long checksum(std::string const & s)
23 auto p = reinterpret_cast<unsigned char const *>(s.c_str());
24 return crc32(0, p, s.size());
27 unsigned long checksum(std::ifstream & ifs)
29 std::istreambuf_iterator<char> beg(ifs);
30 std::istreambuf_iterator<char> end;
32 unsigned long sum = 0;
33 for (auto & it = beg; beg != end; ++it) {
34 unsigned char c = *it;
35 sum = crc32(sum, &c, 1);
40 unsigned long checksum(unsigned char const * beg, unsigned char const * end)
42 return crc32(0, beg, end - beg);
45 } // namespace support