The timcodecb64 class is a base64 encoding and decoding class provided by the Symbian platform. You may not find the description about the base64 encoding and decoding class in the SDK of the official documentation. However, this class does exist in the SDK. Here we provide a simple example of the timcodecb64 class usage.
Sample Code
# Include "imcvcodc. H" // declare the header file in base64
Static hbufc8 * base64encodelc (const tdesc8 & asourcebuf)
{
Timcodecb64 b64;
// Using base64 the size is increased by 1/3.
Hbufc8 * buffer = hbufc8: newl (asourcebuf. Length () + asourcebuf. Length ()/3 );
B64.initialise ();
Tptr8 buffptr = buffer-> des ();
B64.encode (asourcebuf, buffptr );
Return buffer;
}
Static hbufc8 * base64decodelc (const tdesc8 & asourcebuf)
{
Timcodecb64 b64;
Hbufc8 * buffer = hbufc8: newlc (asourcebuf. Length ());
B64.initialise ();
Tptr8 buffptr = buffer-> des ();
B64.decode (asourcebuf, buffptr );
Return buffer;
}
Base64 encoding
// Encode string to base64 encoding with clean Stack
Hbufc8 * encodebuf = stringutil: base64encodelc (_ L8 ("this is test "));
// Change to tdesc16
Hbufc * buff16 = hbufc: newlc (PTR. Length ());
Buff16-> des (). Copy (PTR );
// Do something ....
...
// Clean Buffer
Cleanupstack: popanddestroy (2 );
Result
Vghpcybpcyb0zxn0
Base64 Decoding
// Decode base64 encoding with clean Stack
Hbufc8 * decodebuf = stringutil: base64decodelc (_ L8 ("vghpcybpcyb0zxn0 "));
// Change to tdesc16
Hbufc * buff16 = hbufc: newlc (PTR. Length ());
Buff16-> des (). Copy (PTR );
// Do something
...
// Clean Buffer
Cleanupstack: popanddestroy (2 );
Result
This is test
Prompt
In addition to the header file "imcvcodc. H", you also need to add imut. lib to The. MMP file.
Retrieved from "http://wiki.forum.nokia.com/index.php/Symbian%E5%B9%B3%E5%8F%B0%E4%B8%8BBase64%E7%BC%96%E7%A0%81%E5%8F%8A%E8%A7%A3%E7%A0%81"