mirror of
https://github.com/eosswedenorg/libantelope
synced 2026-06-16 03:34:56 +02:00
include/libeosio/base58.hpp: Change decode function to accept vector instead of string.
This commit is contained in:
parent
ed59959b5b
commit
a99a23ae9b
3 changed files with 8 additions and 6 deletions
|
|
@ -40,8 +40,8 @@ std::string base58_encode(const unsigned char* pbegin, const unsigned char* pend
|
|||
/**
|
||||
* Base58 Decoding functions.
|
||||
*/
|
||||
bool base58_decode(const char* psz, std::string& out);
|
||||
bool base58_decode(const std::string& str, std::string& out);
|
||||
bool base58_decode(const char* psz, std::vector<unsigned char>& out);
|
||||
bool base58_decode(const std::string& str, std::vector<unsigned char>& out);
|
||||
|
||||
/**
|
||||
* Returns true if `ch` is a base58 character, false otherwise.
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ std::string base58_encode(const std::vector<unsigned char>& vch) {
|
|||
return base58_encode(vch.data(), vch.data() + vch.size());
|
||||
}
|
||||
|
||||
bool base58_decode(const char* psz, std::string& out) {
|
||||
bool base58_decode(const char* psz, std::vector<unsigned char>& out) {
|
||||
// Skip leading spaces.
|
||||
while (*psz && is_space(*psz))
|
||||
psz++;
|
||||
|
|
@ -160,7 +160,7 @@ bool base58_decode(const char* psz, std::string& out) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool base58_decode(const std::string& str, std::string& out) {
|
||||
bool base58_decode(const std::string& str, std::vector<unsigned char>& out) {
|
||||
return base58_decode(str.c_str(), out);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,10 +39,12 @@ TEST_CASE("base58_decode") {
|
|||
for(tests::const_iterator it = input.begin(); it != input.end(); it++) {
|
||||
|
||||
SUBCASE(it->name.c_str()) {
|
||||
std::string result;
|
||||
std::vector<unsigned char> result;
|
||||
|
||||
std::vector<unsigned char> expectedOut(it->expectedOut.begin(), it->expectedOut.end());
|
||||
|
||||
CHECK( libeosio::base58_decode(it->in, result) == it->expectedReturn );
|
||||
CHECK( result == it->expectedOut );
|
||||
CHECK( result == expectedOut );
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue