2017-09-10 17:21:19 -07:00
|
|
|
/*
|
|
|
|
|
sha1.hpp - header of
|
|
|
|
|
|
|
|
|
|
============
|
|
|
|
|
SHA-1 in C++
|
|
|
|
|
============
|
|
|
|
|
|
|
|
|
|
100% Public Domain.
|
|
|
|
|
|
|
|
|
|
Original C Code
|
|
|
|
|
-- Steve Reid <steve@edmweb.com>
|
|
|
|
|
Small changes to fit into bglibs
|
|
|
|
|
-- Bruce Guenter <bruce@untroubled.org>
|
|
|
|
|
Translation to simpler C++ Code
|
|
|
|
|
-- Volker Grabsch <vog@notjusthosting.com>
|
|
|
|
|
Safety fixes
|
|
|
|
|
-- Eugene Hopkinson <slowriot at voxelstorm dot com>
|
|
|
|
|
*/
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
#ifndef WPIUTIL_WPI_SHA1_H_
|
|
|
|
|
#define WPIUTIL_WPI_SHA1_H_
|
2017-09-10 17:21:19 -07:00
|
|
|
|
2017-10-21 20:31:20 -07:00
|
|
|
#include <stdint.h>
|
2017-09-10 17:21:19 -07:00
|
|
|
|
|
|
|
|
#include <string>
|
2021-06-06 16:13:58 -07:00
|
|
|
#include <string_view>
|
2017-09-10 17:21:19 -07:00
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
namespace wpi {
|
2017-10-21 20:31:20 -07:00
|
|
|
template <typename T>
|
|
|
|
|
class SmallVectorImpl;
|
2017-09-10 17:21:19 -07:00
|
|
|
class raw_istream;
|
|
|
|
|
|
2017-10-21 20:31:20 -07:00
|
|
|
class SHA1 {
|
|
|
|
|
public:
|
|
|
|
|
SHA1();
|
2021-06-06 16:13:58 -07:00
|
|
|
void Update(std::string_view s);
|
2017-10-21 20:31:20 -07:00
|
|
|
void Update(raw_istream& is);
|
|
|
|
|
std::string Final();
|
2021-06-06 16:13:58 -07:00
|
|
|
std::string_view Final(SmallVectorImpl<char>& buf);
|
|
|
|
|
std::string_view RawFinal(SmallVectorImpl<char>& buf);
|
|
|
|
|
static std::string FromFile(std::string_view filename);
|
2017-10-21 20:31:20 -07:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
uint32_t digest[5];
|
|
|
|
|
unsigned char buffer[64];
|
|
|
|
|
size_t buf_size;
|
|
|
|
|
uint64_t transforms;
|
2017-09-10 17:21:19 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace wpi
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
#endif // WPIUTIL_WPI_SHA1_H_
|