#include <Base64.h>
Definition at line 20 of file Base64.h.
Definition at line 51 of file Base64.cpp.
References string.
Referenced by TEST().
52 if (b64message.length() % 4 != 0 || padding >= 3) {
56 std::unique_ptr<BIO, BIODeleter> bio, b64;
57 size_t decodeLen = b64message.length() * 3/4 - padding;
60 bio.reset(BIO_new_mem_buf((
void*)b64message.data(), -1));
64 b64.reset(BIO_new(BIO_f_base64()));
68 bio.reset(BIO_push(b64.release(), bio.release()));
71 BIO_set_flags(bio.get(), BIO_FLAGS_BASE64_NO_NL);
72 BIO_read(bio.get(), (
char*)result.data(), b64message.length());
73 DCHECK_LE(result.length(), decodeLen);
74 if (result.length() < decodeLen) {
Definition at line 80 of file Base64.cpp.
References folly::Range< Iter >::data(), folly::Range< Iter >::size(), and string.
Referenced by proxygen::HTTP1xCodec::generateWebsocketAccept(), and proxygen::HTTP1xCodec::generateWebsocketKey().
81 std::unique_ptr<BIO, BIODeleter> bio, b64;
84 b64.reset(BIO_new(BIO_f_base64()));
86 throw std::bad_alloc();
88 bio.reset(BIO_new(BIO_s_mem()));
90 throw std::bad_alloc();
92 bio.reset(BIO_push(b64.release(), bio.release()));
95 BIO_set_flags(bio.get(), BIO_FLAGS_BASE64_NO_NL);
96 BIO_write(bio.get(), buffer.
data(), buffer.
size());
97 (void)BIO_flush(bio.get());
98 BIO_get_mem_ptr(bio.get(), &bufferPtr);
99 (void)BIO_set_close(bio.get(), BIO_NOCLOSE);
101 std::string result(bufferPtr->data, bufferPtr->length);
102 BUF_MEM_free(bufferPtr);
constexpr size_type size() const
constexpr Iter data() const
Definition at line 26 of file Base64.cpp.
References c, fizz::decode(), i, string, folly::pushmi::operators::transform, and uint8_t.
27 std::unique_ptr<BIO, BIODeleter> bio, b64;
28 uint8_t padding = (4 - urlB64message.length() % 4) % 4;
33 std::string b64message(urlB64message.length() + padding, 0);
35 urlB64message.begin(), urlB64message.end(), b64message.begin(),
39 }
else if (
c ==
'_') {
44 for (
auto i = urlB64message.length();
i < urlB64message.length() + padding;
48 return decode(b64message, padding);
PUSHMI_INLINE_VAR constexpr detail::transform_fn transform
static std::string decode(const std::string &b64message, int padding)
Definition at line 107 of file Base64.cpp.
References c, encode(), string, folly::pushmi::operators::transform, and uint8_t.
112 sp.begin(), sp.end(), result.begin(),
116 }
else if (
c ==
'/') {
118 }
else if (
c ==
'=') {
123 DCHECK_LE(padding, result.length());
124 result.resize(result.length() - padding);
PUSHMI_INLINE_VAR constexpr detail::transform_fn transform
static std::string encode(folly::ByteRange buffer)
The documentation for this class was generated from the following files: