Core/Data/WebHelpers/base64.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  *
8  * @author: 2018 - Mikee47 <mike@sillyhouse.net>
9  *
10  * Functions added to work with String objects for ease of use.
11  *
12  ****/
13 
14 #pragma once
15 
16 #include "WString.h"
17 
26 size_t base64_min_encode_len(size_t in_len);
27 
35 size_t base64_min_decode_len(size_t in_len);
36 
46 int base64_encode(size_t in_len, const unsigned char* in, size_t out_len, char* out);
47 
53 String base64_encode(const unsigned char* in, size_t in_len);
54 
59 static inline String base64_encode(const String& in)
60 {
61  return base64_encode((unsigned char*)in.c_str(), in.length());
62 }
63 
71 int base64_decode(size_t in_len, const char* in, size_t out_len, unsigned char* out);
72 
78 String base64_decode(const char* in, size_t in_len);
79 
84 static inline String base64_decode(const String& in)
85 {
86  return base64_decode(in.c_str(), in.length());
87 }
size_t base64_min_encode_len(size_t in_len)
Get minimum output buffer size required to encode message of given length.
int base64_encode(size_t in_len, const unsigned char *in, size_t out_len, char *out)
encode binary data into base64 digits with MIME style === pads
size_t base64_min_decode_len(size_t in_len)
Get minimum output buffer size required to decode message of given length.
The String class.
Definition: WString.h:136
int base64_decode(size_t in_len, const char *in, size_t out_len, unsigned char *out)
decode base64 digits with MIME style === pads into binary data
const char * c_str() const
Get a constant (un-modifiable) pointer to String content.
Definition: WString.h:616
size_t length(void) const
Obtain the String length in characters, excluding NUL terminator.
Definition: WString.h:243