Back to Site
Loading...
Searching...
No Matches
sha1.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5#include <cstdint>
6
7namespace librats {
8
9class SHA1 {
10public:
12
13 // Process a single byte
14 void update(uint8_t byte);
15
16 // Process a buffer
17 void update(const uint8_t* data, size_t length);
18
19 // Process a string
20 void update(const std::string& str);
21
22 // Get the final hash as a hex string
23 std::string finalize();
24
25 // Convenience function to hash a string directly
26 static std::string hash(const std::string& input);
27
28 // Convenience function to hash a vector of bytes directly
29 static std::string hash_bytes(const std::vector<uint8_t>& input);
30
31private:
32 void process_block();
33 void reset();
34
35 uint32_t h0, h1, h2, h3, h4;
36 uint8_t buffer[64];
37 size_t buffer_length;
38 uint64_t total_length;
39 bool finalized;
40};
41
42} // namespace librats
std::string finalize()
void update(const std::string &str)
void update(uint8_t byte)
static std::string hash(const std::string &input)
static std::string hash_bytes(const std::vector< uint8_t > &input)
void update(const uint8_t *data, size_t length)