use base64 from boost::beast for basic authorization

This commit is contained in:
PobreGato
2026-08-16 03:56:58 +03:00
parent c0f5798af9
commit 5312aba642
4 changed files with 6 additions and 14 deletions
+5 -1
View File
@@ -11,6 +11,7 @@
#include <stdio.h>
#include <ctime>
#include <charconv>
#include <boost/beast/core/detail/base64.hpp>
#include "util.h"
#include "Base.h"
#include "HTTP.h"
@@ -625,7 +626,10 @@ namespace http
std::string CreateBasicAuthorizationString (const std::string& user, const std::string& pass)
{
if (user.empty () && pass.empty ()) return "";
return "Basic " + i2p::data::ToBase64Standard (user + ":" + pass);
auto credentials = user + ":" + pass;
std::string encoded (boost::beast::detail::base64::encoded_size (credentials.length ()), 0);
encoded.resize (boost::beast::detail::base64::encode (encoded.data (), credentials.data (), credentials.length ()));
return "Basic " + encoded;
}
} // http