C++ Convert String into Base 64
In this Post i will show you how you can encode normal Strings into Base 64. #include <iostream> #include <string> #include<windows.h> using namespace std; static const std :: string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/" ; const char Base64EncodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ; char * Base64EncodeTriplet (byte * vInput, const int & vLength = 3 ) { char * ret = new char [ 5 ]; ret[ 4 ] = '\0' ; long tValue = 0 ; if (vLength >= 1 ) tValue += vInput[ 0 ] << 16 ; if (vLength >= 2 ) tValue += vInput[ 1 ] << 8 ; if (vLength >= 3 ) tValue += vInput[ 2 ]; long tMask; for ( int i = 0 ; i < 4 ; i ++ ) { int bitshift = (( 3 - i) * 6 ); tMask = 63 ; tMa