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