adding base58 helper

This commit is contained in:
Daniel Larimer 2014-06-11 17:28:47 -04:00
parent 8ef1c4e0a7
commit 454da57a32
2 changed files with 7 additions and 0 deletions

View file

@ -4,6 +4,7 @@
namespace fc {
std::string to_base58( const char* d, size_t s );
std::string to_base58( const std::vector<char>& data );
std::vector<char> from_base58( const std::string& base58_str );
size_t from_base58( const std::string& base58_str, char* out_data, size_t out_data_len );
}

View file

@ -609,6 +609,12 @@ std::string to_base58( const char* d, size_t s ) {
return EncodeBase58( (const unsigned char*)d, (const unsigned char*)d+s ).c_str();
}
std::string to_base58( const std::vector<char>& d )
{
if( d.size() )
return to_base58( d.data(), d.size() );
return std::string();
}
std::vector<char> from_base58( const std::string& base58_str ) {
std::vector<unsigned char> out;
if( !DecodeBase58( base58_str.c_str(), out ) ) {