Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 53085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:00:29+00:00 2026-05-10T17:00:29+00:00

Is there a freely available Base64 decoding code snippet in C++?

  • 0

Is there a freely available Base64 decoding code snippet in C++?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:00:30+00:00Added an answer on May 10, 2026 at 5:00 pm

    See Encoding and decoding base 64 with C++.

    Here is the implementation from that page:

    /*    base64.cpp and base64.h     Copyright (C) 2004-2008 René Nyffenegger     This source code is provided 'as-is', without any express or implied    warranty. In no event will the author be held liable for any damages    arising from the use of this software.     Permission is granted to anyone to use this software for any purpose,    including commercial applications, and to alter it and redistribute it    freely, subject to the following restrictions:     1. The origin of this source code must not be misrepresented; you must not       claim that you wrote the original source code. If you use this source code       in a product, an acknowledgment in the product documentation would be       appreciated but is not required.     2. Altered source versions must be plainly marked as such, and must not be       misrepresented as being the original source code.     3. This notice may not be removed or altered from any source distribution.     René Nyffenegger rene.nyffenegger@adp-gmbh.ch  */  static const std::string base64_chars =              "ABCDEFGHIJKLMNOPQRSTUVWXYZ"              "abcdefghijklmnopqrstuvwxyz"              "0123456789+/";   static inline bool is_base64(unsigned char c) {   return (isalnum(c) || (c == '+') || (c == '/')); }  std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {   std::string ret;   int i = 0;   int j = 0;   unsigned char char_array_3[3];   unsigned char char_array_4[4];    while (in_len--) {     char_array_3[i++] = *(bytes_to_encode++);     if (i == 3) {       char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;       char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);       char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);       char_array_4[3] = char_array_3[2] & 0x3f;        for(i = 0; (i <4) ; i++)         ret += base64_chars[char_array_4[i]];       i = 0;     }   }    if (i)   {     for(j = i; j < 3; j++)       char_array_3[j] = '\0';      char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;     char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);     char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);     char_array_4[3] = char_array_3[2] & 0x3f;      for (j = 0; (j < i + 1); j++)       ret += base64_chars[char_array_4[j]];      while((i++ < 3))       ret += '=';    }    return ret;  } std::string base64_decode(std::string const& encoded_string) {   int in_len = encoded_string.size();   int i = 0;   int j = 0;   int in_ = 0;   unsigned char char_array_4[4], char_array_3[3];   std::string ret;    while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {     char_array_4[i++] = encoded_string[in_]; in_++;     if (i ==4) {       for (i = 0; i <4; i++)         char_array_4[i] = 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);       char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];        for (i = 0; (i < 3); i++)         ret += char_array_3[i];       i = 0;     }   }    if (i) {     for (j = i; j <4; j++)       char_array_4[j] = 0;      for (j = 0; j <4; j++)       char_array_4[j] = 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);     char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];      for (j = 0; (j < i - 1); j++) ret += char_array_3[j];   }    return ret; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 92k
  • Answers 92k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I don't think it is failing because of the <br/>… May 11, 2026 at 6:29 pm
  • Editorial Team
    Editorial Team added an answer Use jQuery's context: $doc = $("<div id='myid'><div id='subid'>Text</div></div>"); var data… May 11, 2026 at 6:29 pm
  • Editorial Team
    Editorial Team added an answer i got the answer here.. May 11, 2026 at 6:29 pm

Related Questions

Is there a freely available library to create a MPEG (or any other simple
The theoretical maximum of memory bandwidth for a Core 2 processor with DDR3 dual
I am trying to build a Google Maps-driven web application that can display a
Many of our customers have access to InstallShield, WISE or AdminStudio. These aren't a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.