2010-08-29 09:58:15 -07:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2014-12-16 17:47:57 -08:00
|
|
|
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
2023-01-23 10:31:54 -08:00
|
|
|
// Copyright (c) 2016-2023 The Zcash developers
|
2014-10-30 17:43:19 -07:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2019-07-18 07:16:09 -07:00
|
|
|
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
2010-08-29 09:58:15 -07:00
|
|
|
|
2014-10-30 17:43:19 -07: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 07:47:17 -07: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-30 17:43:19 -07:00
|
|
|
* - E-mail usually won't line-break if there's no punctuation to break at.
|
2015-04-28 07:47:17 -07:00
|
|
|
* - Double-clicking selects the whole string as one word if it's all alphanumeric.
|
2014-10-30 17:43:19 -07:00
|
|
|
*/
|
2011-05-15 00:11:04 -07:00
|
|
|
#ifndef BITCOIN_BASE58_H
|
|
|
|
#define BITCOIN_BASE58_H
|
2010-08-29 09:58:15 -07:00
|
|
|
|
2013-04-12 22:13:08 -07:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2014-04-06 19:30:04 -07:00
|
|
|
/**
|
2014-04-12 14:34:00 -07:00
|
|
|
* Encode a byte sequence as a base58-encoded string.
|
|
|
|
* pbegin and pend cannot be NULL, unless both are.
|
2014-04-06 19:30:04 -07:00
|
|
|
*/
|
2014-04-12 14:34:00 -07:00
|
|
|
std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend);
|
2010-08-29 09:58:15 -07:00
|
|
|
|
2014-04-06 19:30:04 -07:00
|
|
|
/**
|
|
|
|
* Encode a byte vector as a base58-encoded string
|
|
|
|
*/
|
2014-05-09 14:42:20 -07:00
|
|
|
std::string EncodeBase58(const std::vector<unsigned char>& vch);
|
2010-08-29 09:58:15 -07:00
|
|
|
|
2014-04-06 19:30:04 -07:00
|
|
|
/**
|
2014-04-12 14:34:00 -07:00
|
|
|
* Decode a base58-encoded string (psz) into a byte vector (vchRet).
|
|
|
|
* return true if decoding is successful.
|
|
|
|
* psz cannot be NULL.
|
2014-04-06 19:30:04 -07:00
|
|
|
*/
|
2014-04-12 14:34:00 -07:00
|
|
|
bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet);
|
2010-08-29 09:58:15 -07:00
|
|
|
|
2014-04-06 19:30:04 -07:00
|
|
|
/**
|
2014-04-12 14:34:00 -07:00
|
|
|
* Decode a base58-encoded string (str) into a byte vector (vchRet).
|
|
|
|
* return true if decoding is successful.
|
2014-04-06 19:30:04 -07:00
|
|
|
*/
|
2014-05-09 14:42:20 -07:00
|
|
|
bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet);
|
2010-08-29 09:58:15 -07:00
|
|
|
|
2014-04-06 19:30:04 -07:00
|
|
|
/**
|
|
|
|
* Encode a byte vector into a base58-encoded string, including checksum
|
|
|
|
*/
|
2014-05-09 14:42:20 -07:00
|
|
|
std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn);
|
2010-08-29 09:58:15 -07:00
|
|
|
|
2014-04-06 19:30:04 -07:00
|
|
|
/**
|
|
|
|
* Decode a base58-encoded string (psz) that includes a checksum into a byte
|
|
|
|
* vector (vchRet), return true if decoding is successful
|
|
|
|
*/
|
2017-09-19 18:12:25 -07:00
|
|
|
bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet);
|
2010-08-29 09:58:15 -07:00
|
|
|
|
2014-04-06 19:30:04 -07:00
|
|
|
/**
|
|
|
|
* Decode a base58-encoded string (str) that includes a checksum into a byte
|
|
|
|
* vector (vchRet), return true if decoding is successful
|
|
|
|
*/
|
2017-09-19 18:12:25 -07:00
|
|
|
bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet);
|
2018-04-24 07:16:27 -07:00
|
|
|
|
2012-11-09 03:50:59 -08:00
|
|
|
#endif // BITCOIN_BASE58_H
|