Botan 2.19.1
Crypto and TLS for C&
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
14namespace Botan {
15
16/**
17* Perform base58 encoding
18*
19* This is raw base58 encoding, without the checksum
20*/
21std::string
22BOTAN_PUBLIC_API(2,9) base58_encode(const uint8_t input[],
23 size_t input_length);
24
25/**
26* Perform base58 encoding with checksum
27*/
28std::string
29BOTAN_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*/
38std::vector<uint8_t>
39BOTAN_PUBLIC_API(2,9) base58_decode(const char input[],
40 size_t input_length);
41
42/**
43* Perform base58 decoding with checksum
44*/
45std::vector<uint8_t>
46BOTAN_PUBLIC_API(2,9) base58_check_decode(const char input[],
47 size_t input_length);
48
49
50// Some convenience wrappers:
51
52template<typename Alloc>
53inline std::string base58_encode(const std::vector<uint8_t, Alloc>& vec)
54 {
55 return base58_encode(vec.data(), vec.size());
56 }
57
58template<typename Alloc>
59inline std::string base58_check_encode(const std::vector<uint8_t, Alloc>& vec)
60 {
61 return base58_check_encode(vec.data(), vec.size());
62 }
63
64inline std::vector<uint8_t> base58_decode(const std::string& s)
65 {
66 return base58_decode(s.data(), s.size());
67 }
68
69inline 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
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: alg_id.cpp:13
std::vector< uint8_t > base58_check_decode(const char input[], size_t input_length)
Definition: base58.cpp:171
std::string base58_encode(const uint8_t input[], size_t input_length)
Definition: base58.cpp:130
std::string base58_check_encode(const uint8_t input[], size_t input_length)
Definition: base58.cpp:136
std::vector< uint8_t > base58_decode(const char input[], size_t input_length)
Definition: base58.cpp:144
Definition: bigint.h:1143