Add OpenSSL include dir

This commit is contained in:
badaix 2024-06-03 22:30:43 +02:00
parent c1bbfdf167
commit f50a03ba1e
5 changed files with 50 additions and 44 deletions

View file

@ -39,7 +39,7 @@ static inline bool is_base64(unsigned char c)
return ((isalnum(c) != 0) || (c == '+') || (c == '/'));
}
std::string base64_encode(const unsigned char* bytes_to_encode, unsigned int in_len)
std::string base64_encode(const unsigned char* bytes_to_encode, size_t in_len)
{
std::string ret;
int i = 0;
@ -90,7 +90,7 @@ std::string base64_encode(const std::string& text)
std::string base64_decode(const std::string& encoded_string)
{
int in_len = encoded_string.size();
size_t in_len = encoded_string.size();
int i = 0;
int in_ = 0;
unsigned char char_array_4[4], char_array_3[3];
@ -103,7 +103,7 @@ std::string base64_decode(const std::string& encoded_string)
if (i == 4)
{
for (i = 0; i < 4; i++)
char_array_4[i] = base64_chars.find(char_array_4[i]);
char_array_4[i] = static_cast<unsigned char>(base64_chars.find(char_array_4[i]));
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
@ -122,7 +122,7 @@ std::string base64_decode(const std::string& encoded_string)
char_array_4[j] = 0;
for (j = 0; j < 4; j++)
char_array_4[j] = base64_chars.find(char_array_4[j]);
char_array_4[j] = static_cast<unsigned char>(base64_chars.find(char_array_4[j]));
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
@ -136,7 +136,7 @@ std::string base64_decode(const std::string& encoded_string)
}
std::string base64url_encode(const unsigned char* bytes_to_encode, unsigned int in_len)
std::string base64url_encode(const unsigned char* bytes_to_encode, size_t in_len)
{
std::string res = base64_encode(bytes_to_encode, in_len);
std::replace(res.begin(), res.end(), '+', '-');