Read base64 encoded file

Hi Guys,

I want to read a base64 encoded file in Linux. I think I can open it as text mode. I tried with a simple code with a while loop to read each line from the file opened as text & it can display the expect contents onto display. This displayed output is same as the output of "cat <file>".

2 questions;

1. Is it correct to read this base64 encode file as text?
2. I know how to take a text file into a string using "stringstream" but when I try the same code, it does not work. Any idea?

What am I doing wrong with this handling of bsae64 cncoded file?


// function to convert file to a string
string FileToString(string filename)
{

ifstream fileToString(filename.c_str());
stringstream NewFileString;
NewFileString << fileToString.rdbuf();

return(NewFileString.str());

}

Thanks

Mathew

You have to actually decode the string.
See: http://en.wikipedia.org/wiki/Base64#Examples
Topic archived. No new replies allowed.