fix(base58): basen::Exception

This commit is contained in:
2024-09-30 17:47:08 +03:00
parent edcaebcf53
commit 8169651729
5 changed files with 22 additions and 26 deletions

View File

@ -17,34 +17,35 @@ namespace base58
bool isValid(std::string_view str) noexcept;
/**
* @throw std::overflow_error if if there is an overflow
* @throw basen::Exception(OVERFLOW) if there is an overflow
*/
size_t sizeEncoded(std::span<const uint8_t> data) noexcept;
size_t sizeEncoded(std::span<const uint8_t> data);
size_t sizeDecoded(std::string_view str) noexcept;
/**
* @return number of leading chars, which should be trimmed
* @warning contain leading zeros, returns count of them
*/
size_t encode(const uint8_t *data, size_t data_size, char *str, size_t str_size) noexcept;
std::string encode(std::span<const uint8_t> data) noexcept;
size_t encode(const uint8_t *data, size_t data_size, char *str, size_t str_size);
std::string encode(std::span<const uint8_t> data);
/**
* @return number of leading chars, which should be trimmed
* @warning contain leading zeros, returns count of them
*/
size_t decode(const char *str, size_t str_size, uint8_t *data, size_t data_size) noexcept;
std::vector<uint8_t> decode(std::string_view str) noexcept;
size_t decode(const char *str, size_t str_size, uint8_t *data, size_t data_size);
std::vector<uint8_t> decode(std::string_view str);
/**
* @param data vector or span of data which you want to encode
* @return encoded string + 4 first bytes of double sha256
*/
std::string encodeCheck(std::span<const uint8_t> data) noexcept;
std::string encodeCheck(std::span<const uint8_t> data);
/**
* @param str string or string_view which you want to decode
* @return decoded data without 4 first bytes of double sha256
* @throw std::logic_error checksum incorrect
* @throw basen::Exception(PADDING) if str size < 4
* @throw basen::Exception(CHECKSUM) checksum incorrect
*/
std::vector<uint8_t> decodeCheck(std::string_view str);
}

View File

@ -14,7 +14,7 @@ namespace base64
bool isValid(std::string_view str) noexcept;
/**
* @throw basen::Exception(OVERFLOW) if if there is an overflow
* @throw basen::Exception(OVERFLOW) if there is an overflow
*/
size_t sizeEncoded(std::span<const uint8_t> data);
size_t sizeDecoded(std::string_view str) noexcept;

View File

@ -14,7 +14,7 @@ namespace hex
bool isValid(std::string_view str) noexcept;
/**
* @throw basen::Exception(OVERFLOW) if if there is an overflow
* @throw basen::Exception(OVERFLOW) if there is an overflow
*/
size_t sizeEncoded(std::span<const uint8_t> data);
size_t sizeDecoded(std::string_view str) noexcept;