2010-08-29 18:58:15 +02:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2018-07-27 00:36:45 +02:00
|
|
|
// Copyright (c) 2009-2018 The Bitcoin Core developers
|
2014-10-31 01:43:19 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2012-05-18 16:02:28 +02:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2014-10-31 01:43:19 +01:00
|
|
|
/**
|
|
|
|
* Why base-58 instead of standard base-64 encoding?
|
|
|
|
* - Don't want 0OIl characters that look the same in some fonts and
|
2015-04-28 16:47:17 +02:00
|
|
|
* could be used to create visually identical looking data.
|
|
|
|
* - A string with non-alphanumeric characters is not as easily accepted as input.
|
2014-10-31 01:43:19 +01:00
|
|
|
* - E-mail usually won't line-break if there's no punctuation to break at.
|
2015-04-28 16:47:17 +02:00
|
|
|
* - Double-clicking selects the whole string as one word if it's all alphanumeric.
|
2014-10-31 01:43:19 +01:00
|
|
|
*/
|
2011-05-15 09:11:04 +02:00
|
|
|
#ifndef BITCOIN_BASE58_H
|
|
|
|
#define BITCOIN_BASE58_H
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2018-09-25 07:00:36 +02:00
|
|
|
#include <attributes.h>
|
|
|
|
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2014-04-07 04:30:04 +02:00
|
|
|
/**
|
2014-04-12 23:34:00 +02:00
|
|
|
* Encode a byte sequence as a base58-encoded string.
|
2017-08-07 07:36:37 +02:00
|
|
|
* pbegin and pend cannot be nullptr, unless both are.
|
2014-04-07 04:30:04 +02:00
|
|
|
*/
|
2014-04-12 23:34:00 +02:00
|
|
|
std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend);
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2014-04-07 04:30:04 +02:00
|
|
|
/**
|
|
|
|
* Encode a byte vector as a base58-encoded string
|
|
|
|
*/
|
2014-05-09 23:42:20 +02:00
|
|
|
std::string EncodeBase58(const std::vector<unsigned char>& vch);
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2014-04-07 04:30:04 +02:00
|
|
|
/**
|
2014-04-12 23:34:00 +02:00
|
|
|
* Decode a base58-encoded string (psz) into a byte vector (vchRet).
|
|
|
|
* return true if decoding is successful.
|
2017-08-07 07:36:37 +02:00
|
|
|
* psz cannot be nullptr.
|
2014-04-07 04:30:04 +02:00
|
|
|
*/
|
2018-09-25 07:00:36 +02:00
|
|
|
NODISCARD bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet);
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2014-04-07 04:30:04 +02:00
|
|
|
/**
|
2014-04-12 23:34:00 +02:00
|
|
|
* Decode a base58-encoded string (str) into a byte vector (vchRet).
|
|
|
|
* return true if decoding is successful.
|
2014-04-07 04:30:04 +02:00
|
|
|
*/
|
2018-09-25 07:00:36 +02:00
|
|
|
NODISCARD bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet);
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2014-04-07 04:30:04 +02:00
|
|
|
/**
|
|
|
|
* Encode a byte vector into a base58-encoded string, including checksum
|
|
|
|
*/
|
2014-05-09 23:42:20 +02:00
|
|
|
std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn);
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2014-04-07 04:30:04 +02:00
|
|
|
/**
|
|
|
|
* Decode a base58-encoded string (psz) that includes a checksum into a byte
|
|
|
|
* vector (vchRet), return true if decoding is successful
|
|
|
|
*/
|
2018-09-25 07:00:36 +02:00
|
|
|
NODISCARD bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet);
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2014-04-07 04:30:04 +02:00
|
|
|
/**
|
|
|
|
* Decode a base58-encoded string (str) that includes a checksum into a byte
|
|
|
|
* vector (vchRet), return true if decoding is successful
|
|
|
|
*/
|
2018-09-25 07:00:36 +02:00
|
|
|
NODISCARD bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet);
|
2017-08-23 03:02:33 +02:00
|
|
|
|
2012-11-09 12:50:59 +01:00
|
|
|
#endif // BITCOIN_BASE58_H
|