Botan  2.19.1
Crypto and TLS for C++11
base58.h
Go to the documentation of this file.
1 /*
2 * (C) 2018 Jack Lloyd
3 *
4 * Botan is released under the Simplified BSD License (see license.txt)
5 */
6 
7 #ifndef BOTAN_BASE58_CODEC_H_
8 #define BOTAN_BASE58_CODEC_H_
9 
10 #include <botan/secmem.h>
11 #include <vector>
12 #include <string>
13 
14 namespace Botan {
15 
16 /**
17 * Perform base58 encoding
18 *
19 * This is raw base58 encoding, without the checksum
20 */
21 std::string
22 BOTAN_PUBLIC_API(2,9) base58_encode(const uint8_t input[],
23  size_t input_length);
24 
25 /**
26 * Perform base58 encoding with checksum
27 */
28 std::string
29 BOTAN_PUBLIC_API(2,9) base58_check_encode(const uint8_t input[],
30  size_t input_length);
31 
32 
33 /**
34 * Perform base58 decoding
35 *
36 * This is raw base58 encoding, without the checksum
37 */
38 std::vector<uint8_t>
39 BOTAN_PUBLIC_API(2,9) base58_decode(const char input[],
40  size_t input_length);
41 
42 /**
43 * Perform base58 decoding with checksum
44 */
45 std::vector<uint8_t>
46 BOTAN_PUBLIC_API(2,9) base58_check_decode(const char input[],
47  size_t input_length);
48 
49 
50 // Some convenience wrappers:
51 
52 template<typename Alloc>
53 inline std::string base58_encode(const std::vector<uint8_t, Alloc>& vec)
54  {
55  return base58_encode(vec.data(), vec.size());
56  }
57 
58 template<typename Alloc>
59 inline std::string base58_check_encode(const std::vector<uint8_t, Alloc>& vec)
60  {
61  return base58_check_encode(vec.data(), vec.size());
62  }
63 
64 inline std::vector<uint8_t> base58_decode(const std::string& s)
65  {
66  return base58_decode(s.data(), s.size());
67  }
68 
69 inline std::vector<uint8_t> base58_check_decode(const std::string& s)
70  {
71  return base58_check_decode(s.data(), s.size());
72  }
73 
74 }
75 
76 #endif
std::vector< uint8_t > base58_check_decode(const char input[], size_t input_length)
Definition: base58.cpp:171
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: bigint.h:1143
std::string base58_encode(const uint8_t input[], size_t input_length)
Definition: base58.cpp:130
std::vector< uint8_t > base58_decode(const char input[], size_t input_length)
Definition: base58.cpp:144
Definition: alg_id.cpp:13
std::string base58_check_encode(const uint8_t input[], size_t input_length)
Definition: base58.cpp:136