hdac SDK
SDK for hdac blockchain development
base58.h
1 #ifndef BASE58_H
2 #define BASE58_H
3 
4 #include <utils/utilstrencodings.h>
5 //#include <utils/allocators.h>
6 #include <utils/zero_after_free_allocator.h>
7 #include <vector>
12 std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend);
13 
17 std::string EncodeBase58(const std::vector<unsigned char>& vch);
18 
24 bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet);
25 
30 bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet);
31 
35 std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn, int32_t addressChecksumValue);
36 
41 inline bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet, int32_t addressChecksumValue);
42 
47 inline bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet, int32_t addressChecksumValue);
48 
53 {
54 protected:
56  std::vector<unsigned char> vchVersion;
57 
59  typedef std::vector<unsigned char, zero_after_free_allocator<unsigned char> > vector_uchar;
60  vector_uchar vchData;
61 
62  CBase58Data(int32_t checksumValue);
63  void SetData(const std::vector<unsigned char> &vchVersionIn, const void* pdata, size_t nSize);
64  void SetData(const std::vector<unsigned char> &vchVersionIn, const unsigned char *pbegin, const unsigned char *pend);
65 
66 public:
67  bool SetString(const char* psz, unsigned int nVersionBytes = 1);
68  bool SetString(const std::string& str, unsigned int pubkeyAddressSize);
69  std::string ToString() const;
70  int CompareTo(const CBase58Data& b58) const;
71 
72  bool operator==(const CBase58Data& b58) const { return CompareTo(b58) == 0; }
73  bool operator<=(const CBase58Data& b58) const { return CompareTo(b58) <= 0; }
74  bool operator>=(const CBase58Data& b58) const { return CompareTo(b58) >= 0; }
75  bool operator< (const CBase58Data& b58) const { return CompareTo(b58) < 0; }
76  bool operator> (const CBase58Data& b58) const { return CompareTo(b58) > 0; }
77 
78 private:
79  int32_t _checksumValue;
80 };
81 
82 #endif // BASE58_H
std::vector< unsigned char, zero_after_free_allocator< unsigned char > > vector_uchar
the actually encoded data
Definition: base58.h:59
Definition: base58.h:52
std::vector< unsigned char > vchVersion
the version byte(s)
Definition: base58.h:56