Furrent
|
Typedefs | |
using | hash_t = std::array< uint8_t, 20 > |
Type for a SHA1 hash. More... | |
Enumerations | |
enum | HashError { HashError::MalformedPieceHashesString, HashError::PieceHashesStringTooLarge } |
Functions | |
std::string | error_to_string (HashError error) |
Function to translate an HashError to a string. More... | |
std::string | hash_to_str (const hash_t &hash) |
std::string | hash_to_hex (const hash_t &hash) |
Returns an hex string for the provided hash. More... | |
hash_t | compute_info_hash (const std::string &bencoded_info_dict) |
Computes the info hash given a bencoded string for the .torrent info dict. More... | |
util::Result< std::vector< hash_t >, HashError > | split_piece_hashes (const std::string &piece_hashes_str) |
bool | verify_piece (const std::vector< uint8_t > &piece, hash_t hash) |
Checks that a downloaded piece matches the provided hash. More... | |
using fur::hash::hash_t = typedef std::array<uint8_t, 20> |
Type for a SHA1 hash.
|
strong |
hash_t fur::hash::compute_info_hash | ( | const std::string & | bencoded_info_dict | ) |
Computes the info hash given a bencoded string for the .torrent info dict.
std::string fur::hash::error_to_string | ( | const HashError | error | ) |
Function to translate an HashError to a string.
std::string fur::hash::hash_to_hex | ( | const hash_t & | hash | ) |
Returns an hex string for the provided hash.
std::string fur::hash::hash_to_str | ( | const hash_t & | hash | ) |
Encodes an hash to a string. Note that we're forcing the compiler to make "char" unsigned so a string can contain arbitrary bytes
util::Result< std::vector< hash_t >, HashError > fur::hash::split_piece_hashes | ( | const std::string & | pieces | ) |
Takes a string with the hashes of pieces from a torrent file and parses them into a vector of "hash_t". Each hash is 20 bytes long
bool fur::hash::verify_piece | ( | const std::vector< uint8_t > & | piece, |
hash_t | hash | ||
) |
Checks that a downloaded piece matches the provided hash.