| 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 |
| 16 | // SHA1.h |
| 17 |
| 18 | #pragma once |
| 19 |
| 20 | #include <cstdint> |
| 21 | #include <iostream> |
| 22 | #include <string> |
| 23 |
| 24 | namespace toolkit { |
| 25 |
| 26 | class SHA1 final |
| 27 | { |
| 28 | public: |
| 29 | SHA1(); |
| 30 |
| 31 | void update(const std::string &s); |
| 32 | void update(std::istream &is); |
| 33 | std::string final(); |
| 34 | std::string final_bin(); |
| 35 |
| 36 | static std::string from_file(const std::string &filename); |
| 37 |
| 38 | static std::string encode(const std::string &s); |
| 39 | static std::string encode_bin(const std::string &s); |
| 40 |
| 41 | private: |
| 42 | uint32_t digest[5]; |
| 43 | std::string buffer; |
| 44 | uint64_t transforms; |
| 45 | }; |
| 46 |
| 47 | }//namespace toolkit |