Botan  2.11.0
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
27 *
28 * This is raw base58 encoding, without the checksum
29 */
30 /**
31 * Perform base58 encoding with checksum
32 */
33 std::string
34 BOTAN_PUBLIC_API(2,9) base58_check_encode(const uint8_t input[],
35  size_t input_length);
36 
37 
38 /**
39 * Perform base58 decoding
40 *
41 * This is raw base58 encoding, without the checksum
42 */
43 std::vector<uint8_t>
44 BOTAN_PUBLIC_API(2,9) base58_decode(const char input[],
45  size_t input_length);
46 
47 /**
48 * Perform base58 decoding with checksum
49 *
50 * This is raw base58 encoding, without the checksum
51 */
52 std::vector<uint8_t>
53 BOTAN_PUBLIC_API(2,9) base58_check_decode(const char input[],
54  size_t input_length);
55 
56 
57 // Some convenience wrappers:
58 
59 template<typename Alloc>
60 inline std::string base58_encode(const std::vector<uint8_t, Alloc>& vec)
61  {
62  return base58_encode(vec.data(), vec.size());
63  }
64 
65 template<typename Alloc>
66 inline std::string base58_check_encode(const std::vector<uint8_t, Alloc>& vec)
67  {
68  return base58_check_encode(vec.data(), vec.size());
69  }
70 
71 inline std::vector<uint8_t> base58_decode(const std::string& s)
72  {
73  return base58_decode(s.data(), s.size());
74  }
75 
76 inline std::vector<uint8_t> base58_check_decode(const std::string& s)
77  {
78  return base58_check_decode(s.data(), s.size());
79  }
80 
81 }
82 
83 #endif
std::vector< uint8_t > base58_check_decode(const char input[], size_t input_length)
Definition: base58.cpp:160
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: bigint.h:1136
std::string base58_encode(const uint8_t input[], size_t input_length)
Definition: base58.cpp:117
std::vector< uint8_t > base58_decode(const char input[], size_t input_length)
Definition: base58.cpp:131
Definition: alg_id.cpp:13
std::string base58_check_encode(const uint8_t input[], size_t input_length)
Definition: base58.cpp:123