github.com/igggame/nebulas-go@v2.1.0+incompatible/nbre/common/base58.h (about) 1 // Copyright (c) 2009-2010 Satoshi Nakamoto 2 // Copyright (c) 2009-2017 The Bitcoin Core developers 3 // Distributed under the MIT software license, see the accompanying 4 // file COPYING or http://www.opensource.org/licenses/mit-license.php. 5 6 /** 7 * Why base-58 instead of standard base-64 encoding? 8 * - Don't want 0OIl characters that look the same in some fonts and 9 * could be used to create visually identical looking data. 10 * - A string with non-alphanumeric characters is not as easily accepted as 11 * input. 12 * - E-mail usually won't line-break if there's no punctuation to break at. 13 * - Double-clicking selects the whole string as one word if it's all 14 * alphanumeric. 15 */ 16 #pragma once 17 18 #ifndef BITCOIN_BASE58_H 19 #define BITCOIN_BASE58_H 20 21 #include <string> 22 #include <vector> 23 24 namespace neb { 25 /** 26 * Encode a byte sequence as a base58-encoded string. 27 * pbegin and pend cannot be nullptr, unless both are. 28 */ 29 std::string encode_base58(const unsigned char *pbegin, 30 const unsigned char *pend); 31 32 /** 33 * Encode a byte vector as a base58-encoded string 34 */ 35 std::string encode_base58(const std::vector<unsigned char> &vch); 36 37 /** 38 * Decode a base58-encoded string (psz) into a byte vector (vchRet). 39 * return true if decoding is successful. 40 * psz cannot be nullptr. 41 */ 42 bool decode_base58(const char *psz, std::vector<unsigned char> &vchRet); 43 44 /** 45 * Decode a base58-encoded string (str) into a byte vector (vchRet). 46 * return true if decoding is successful. 47 */ 48 bool decode_base58(const std::string &str, std::vector<unsigned char> &vchRet); 49 50 } // namespace neb 51 #endif // BITCOIN_BASE58_H