Botan 3.11.0
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/types.h>
11
12#include <span>
13#include <string>
14#include <string_view>
15#include <vector>
16
17namespace Botan {
18
19/**
20* Perform base58 encoding
21*
22* This is raw base58 encoding, without the checksum
23*/
24std::string BOTAN_PUBLIC_API(2, 9) base58_encode(const uint8_t input[], size_t input_length);
25
26/**
27* Perform base58 encoding with checksum
28*/
29std::string BOTAN_PUBLIC_API(2, 9) base58_check_encode(const uint8_t input[], size_t input_length);
30
31/**
32* Perform base58 decoding
33*
34* This is raw base58 encoding, without the checksum
35*/
36std::vector<uint8_t> BOTAN_PUBLIC_API(2, 9) base58_decode(const char input[], size_t input_length);
37
38/**
39* Perform base58 decoding with checksum
40*/
41std::vector<uint8_t> BOTAN_PUBLIC_API(2, 9) base58_check_decode(const char input[], size_t input_length);
42
43// Some convenience wrappers:
44
45inline std::string base58_encode(std::span<const uint8_t> vec) {
46 return base58_encode(vec.data(), vec.size());
47}
48
49inline std::string base58_check_encode(std::span<const uint8_t> vec) {
50 return base58_check_encode(vec.data(), vec.size());
51}
52
53inline std::vector<uint8_t> base58_decode(std::string_view s) {
54 return base58_decode(s.data(), s.size());
55}
56
57inline std::vector<uint8_t> base58_check_decode(std::string_view s) {
58 return base58_check_decode(s.data(), s.size());
59}
60
61} // namespace Botan
62
63#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
std::vector< uint8_t > base58_check_decode(const char input[], size_t input_length)
Definition base58.cpp:239
std::string base58_encode(const uint8_t input[], size_t input_length)
Definition base58.cpp:181
std::string base58_check_encode(const uint8_t input[], size_t input_length)
Definition base58.cpp:186
std::vector< uint8_t > base58_decode(const char input[], size_t input_length)
Definition base58.cpp:193