Base64 encoding and decoding
A small class implementing base 64 (RFC 2045) encoding and decoding.
Code is based on the original GPLed work by Dawit Alemayehu and Rik Hemsley (KDE development team).
Many changes have been made and the routines should be slightly faster now.
- 2006-06-09 Minor changes (documentation and binary compatibility).
- 2005-09-30 First public release.
- Qt interface for quickly base 64 encoding or decoding of byte arrays.
- Supports both QByteArray and QBitArray.
- Code should be endianness-aware (no known endianness-related known issues so far ;).
QByteArray ba1 = Base64::decode(myEncodedString1);
QBitArray ba2 = Base64::decode(myEncodedString2, myBitCount);
QByteArray buffer = myQFile.readAll();
QString b64string = Base64::encode(buffer);
Everything is static, so you don't need to instantiate any class.
About the KDE code
The original Alemayehu and Hemsley version did not ignore padding-chars during decoding (see RFC 2045),
this version does.
Line length limit
RFC requires base 64 encoded strings to be no longer than 76 characters. The Base64 class adds a CR/LN pair
after 76 chars on a per-request basis (the limitLines parameter in the