   Base64 encoding WITHOUT std::string
  Is there any function that encodes data to base64 which you can call without std::string. The data that has to be encrypted uses the NOTHING character ((char)0, chr(0), %00, 00h, 0x00, etc.), and thus can''t be handeled using std::string.So i have:char *Data = new char[nSize];Which contains the data of an EXE file. Is there any function I can encode it to Base64, for example using:Encode(Data);10x...H4ck3r  
  Look at this sample: http://support.microsoft.com/default.aspx?scid=KB;en-us;191239  ;  There''s no source code with that sample!  ;  Er, did you download B64_samp.exe?  It''s got source code...    If I had my way, I''d have all of you shot!codeka.com - Just click it.    ;quote:Original post by H4ck3r  The data that has to be encrypted uses the NOTHING character ((char)0, chr(0), %00, 00h, 0x00, etc.), and thus can''t be handeled using std::string.  Say what? std::string can hold any number of ''\0'' chars, it ain''t terminated at the first zero char.   const char* theData = "\0\0\0";std::string theString(theData, 3);assert(theString.size() == 3);assert(memcmp(theString.data(), theData, 3) == 0);   Update GameDev.net system time campaign: ''date ddmmHHMMYYYY'';  What''s wrong with this, then://Open the fileFILE* file = fopen("F:\\Setup.exe", "rb");//Is the file opened?if(file == NULL)return 0;//Yes, jump to the end...fseek(file, 0, SEEK_END);//Where am I, that''s the size!int nSize = ftell(file);//Jump to the begin of the filefseek(file, 0, SEEK_SET);//Create the buffer where the file-data will be storedchar *pText = new char[nSize];//Read the file and store it in pTextfread(pText, sizeof(char), nSize, file);//Close the filefclose(file);//Encrypt the data and send it...Send(mail, (char*)Base64::Encode(pText).c_str());Send is a working function I made myself. Base64::Encode(pText) returns TVqQ. strlen(pText) = 3. If I open the file in a hex editor, the 13th char will be FF, and yes, pText[12] = (char)255.So it seems that the error occurs in Base64::Encode(pText). What else am I doing wrong!?  ;quote:Original post by H4ck3r  Send(mail, (char*) Base64::Encode(pText).c_str());  If that is the same Base64::Encode that I posted in another topic, you know it takes a std::string as its parameter. You must create a std::string using the constructor where you tell the size of the buffer:   std::string plaintext(pText, nSize); // This will create a std::string containing nSize characters of the buffer.std::string base64text = Base64::Encode(plaintext);Send(mail, (char*) base64text.c_str());   Update GameDev.net system time campaign: ''date ddmmHHMMYYYY'';  The thing I think you are doing wrong is that you think that strlen will return the length of a buffer, but it doesn''t, it only counts the number of characters to the first ''\0'' character. ''\0'' is a valid character as any other, but with C/C++ zero-terminated strings (char*) this character marks the end of the string. You can also have char* buffers that aren''t zero-terminated, but then it is up to you to know the size of the buffer. This is the way it is in your case.Another tip for Base64 is to read part of this article: Dr.Dobb''s - MIME and Internet Mail[^]    Update GameDev.net system time campaign: ''date ddmmHHMMYYYY'';  10x, dalleboy, it''s working!I would like to thank dalleboy for his good help!Also I would like to thank Dean Harding for his comment (which I didn''t use. but 10x anyway)And I would like to thank Anonymous Poster.And my parent.LOL  ;  You are welcome, glad to be to any help... Update GameDev.net system time campaign: ''date ddmmHHMMYYYY''