librats
Features
Quick Start
API Reference
GitHub
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
7
namespace
librats
{
8
9
class
SHA1
{
10
public
:
11
SHA1
();
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
31
private
:
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
librats::SHA1
Definition
sha1.h:9
librats::SHA1::finalize
std::string finalize()
librats::SHA1::SHA1
SHA1()
librats::SHA1::update
void update(const std::string &str)
librats::SHA1::update
void update(uint8_t byte)
librats::SHA1::hash
static std::string hash(const std::string &input)
librats::SHA1::hash_bytes
static std::string hash_bytes(const std::vector< uint8_t > &input)
librats::SHA1::update
void update(const uint8_t *data, size_t length)
librats
Definition
librats.h:34