Go to the documentation of this file.
13 using hash_t = std::array<uint8_t, 20>;
36 const std::string& pieces);
hash_t compute_info_hash(const std::string &bencoded_info_dict)
Computes the info hash given a bencoded string for the .torrent info dict.
Definition: hash.cpp:35
util::Result< std::vector< hash_t >, HashError > split_piece_hashes(const std::string &piece_hashes_str)
Definition: hash.cpp:47
@ PieceHashesStringTooLarge
Used to handle errors without using exceptions.
Definition: result.hpp:18
bool verify_piece(const std::vector< uint8_t > &piece, hash_t hash)
Checks that a downloaded piece matches the provided hash.
Definition: hash.cpp:79
std::array< uint8_t, 20 > hash_t
Type for a SHA1 hash.
Definition: hash.hpp:13
HashError
Definition: hash.hpp:15
std::string error_to_string(const HashError error)
Function to translate an HashError to a string.
Definition: hash.cpp:14
std::string hash_to_hex(const hash_t &hash)
Returns an hex string for the provided hash.
Definition: hash.cpp:29
std::string hash_to_str(const hash_t &hash)
Definition: hash.cpp:25
@ MalformedPieceHashesString