summaryrefslogtreecommitdiffstats
path: root/comm/third_party/botan/src/lib/codec/base58/base58.h
blob: 4654a0557cc2afcb95ed33a9f4ad5bb5d2cd6fd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* (C) 2018 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#ifndef BOTAN_BASE58_CODEC_H_
#define BOTAN_BASE58_CODEC_H_

#include <botan/secmem.h>
#include <vector>
#include <string>

namespace Botan {

/**
* Perform base58 encoding
*
* This is raw base58 encoding, without the checksum
*/
std::string
BOTAN_PUBLIC_API(2,9) base58_encode(const uint8_t input[],
                                    size_t input_length);

/**
* Perform base58 encoding with checksum
*/
std::string
BOTAN_PUBLIC_API(2,9) base58_check_encode(const uint8_t input[],
                                          size_t input_length);


/**
* Perform base58 decoding
*
* This is raw base58 encoding, without the checksum
*/
std::vector<uint8_t>
BOTAN_PUBLIC_API(2,9) base58_decode(const char input[],
                                    size_t input_length);

/**
* Perform base58 decoding with checksum
*/
std::vector<uint8_t>
BOTAN_PUBLIC_API(2,9) base58_check_decode(const char input[],
                                          size_t input_length);


// Some convenience wrappers:

template<typename Alloc>
inline std::string base58_encode(const std::vector<uint8_t, Alloc>& vec)
   {
   return base58_encode(vec.data(), vec.size());
   }

template<typename Alloc>
inline std::string base58_check_encode(const std::vector<uint8_t, Alloc>& vec)
   {
   return base58_check_encode(vec.data(), vec.size());
   }

inline std::vector<uint8_t> base58_decode(const std::string& s)
   {
   return base58_decode(s.data(), s.size());
   }

inline std::vector<uint8_t> base58_check_decode(const std::string& s)
   {
   return base58_check_decode(s.data(), s.size());
   }

}

#endif