25#ifndef JOIN_CRYPTO_BASE64_HPP
26#define JOIN_CRYPTO_BASE64_HPP
52 std::stringstream oss;
53 for (
size_t i = 0; i < bin.size (); ++i)
55 oss << std::hex << std::setw (2) << std::setfill ('0') << static_cast<uint32_t> (bin[i]);
114 virtual int_type
overflow (int_type c = traits_type::eof ())
override;
236 virtual int_type
overflow (int_type c = traits_type::eof ())
override;
326 static std::string
encode (
const char* data,
size_t size);
333 static std::string
encode (
const std::string& data);
base64 encode, decode class.
Definition base64.hpp:308
static std::string encode(const char *data, size_t size)
encode data.
Definition base64.cpp:345
static BytesArray decode(const std::string &data)
decode a base64 encoded string.
Definition base64.cpp:374
Base64()=delete
create the Base64 instance.
~Base64()=delete
destroy the Base64 instance.
decoder.
Definition base64.hpp:255
Decoder(const Decoder &other)=delete
copy constructor.
Decoderbuf _decoderbuf
associated decoder stream buffer.
Definition base64.hpp:301
Decoder()
default constructor.
Definition base64.cpp:300
Decoder & operator=(const Decoder &other)=delete
copy assignment operator.
BytesArray get()
get decoded data.
Definition base64.cpp:331
virtual ~Decoder()=default
destroy instance.
decoder stream buffer.
Definition base64.hpp:186
static const std::streamsize _bufsize
internal buffer size.
Definition base64.hpp:239
Decoderbuf & operator=(const Decoderbuf &other)=delete
copy assignment operator.
Decoderbuf(const Decoderbuf &other)=delete
copy constructor.
std::unique_ptr< char[]> _buf
internal buffer.
Definition base64.hpp:242
BytesArray _out
output buffer.
Definition base64.hpp:248
EvpEncodeCtxPtr _decodectx
decode context.
Definition base64.hpp:245
Decoderbuf()
create decoder stream buffer instance.
Definition base64.cpp:191
virtual ~Decoderbuf()=default
destroy encoder stream buffer instance.
virtual int_type overflow(int_type c=traits_type::eof()) override
writes characters to the associated output sequence from the put area.
Definition base64.cpp:249
BytesArray get()
get decoded data.
Definition base64.cpp:225
encoder.
Definition base64.hpp:133
std::string get()
get encoded string.
Definition base64.cpp:177
Encoder & operator=(const Encoder &other)=delete
copy assignment operator.
virtual ~Encoder()=default
destroy instance.
Encoderbuf _encoderbuf
associated encoder stream buffer.
Definition base64.hpp:179
Encoder(const Encoder &other)=delete
copy constructor.
Encoder()
default constructor.
Definition base64.cpp:146
encoder stream buffer.
Definition base64.hpp:64
virtual ~Encoderbuf()=default
destroy encoder stream buffer instance.
Encoderbuf & operator=(const Encoderbuf &other)=delete
copy assignment operator.
std::string get()
get encoded string.
Definition base64.cpp:75
Encoderbuf(const Encoderbuf &other)=delete
copy constructor.
virtual int_type overflow(int_type c=traits_type::eof()) override
writes characters to the associated output sequence from the put area.
Definition base64.cpp:99
std::string _out
output buffer.
Definition base64.hpp:126
EvpEncodeCtxPtr _encodectx
encode context.
Definition base64.hpp:123
std::unique_ptr< char[]> _buf
internal buffer.
Definition base64.hpp:120
Encoderbuf()
create encoder stream buffer instance.
Definition base64.cpp:41
static const std::streamsize _bufsize
internal buffer size.
Definition base64.hpp:117
Definition acceptor.hpp:32
std::unique_ptr< EVP_ENCODE_CTX, EvpEncodeCtxDelete > EvpEncodeCtxPtr
Definition openssl.hpp:118
std::string bin2hex(const BytesArray &bin)
convert bytes array to string.
Definition base64.hpp:50
std::vector< uint8_t > BytesArray
bytes array.
Definition base64.hpp:43