SHA1.h 942 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // 100% Public Domain.
  2. //
  3. // Original C Code
  4. // -- Steve Reid <steve@edmweb.com>
  5. // Small changes to fit into bglibs
  6. // -- Bruce Guenter <bruce@untroubled.org>
  7. // Translation to simpler C++ Code
  8. // -- Volker Grabsch <vog@notjusthosting.com>
  9. // Safety fixes
  10. // -- Eugene Hopkinson <slowriot at voxelstorm dot com>
  11. // Adapt for project
  12. // Dmitriy Khaustov <khaustov.dm@gmail.com>
  13. //
  14. // File created on: 2017.02.25
  15. // SHA1.h
  16. #pragma once
  17. #include <cstdint>
  18. #include <iostream>
  19. #include <string>
  20. class SHA1 final
  21. {
  22. public:
  23. SHA1();
  24. void update(const std::string &s);
  25. void update(std::istream &is);
  26. std::string final();
  27. std::string final_bin();
  28. static std::string from_file(const std::string &filename);
  29. static std::string encode(const std::string &s);
  30. static std::string encode_bin(const std::string &s);
  31. private:
  32. uint32_t digest[5];
  33. std::string buffer;
  34. uint64_t transforms;
  35. };