sl@0: // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // File contains internal classes for Ascii To Base64 converison sl@0: // and vice-versa. sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file TConvBase64.h sl@0: @internalAll sl@0: @released sl@0: */ sl@0: sl@0: #ifndef __TCONVBASE64_H__ sl@0: #define __TCONVBASE64_H__ sl@0: sl@0: #include sl@0: sl@0: sl@0: const TInt KMaxB64EncodedCharsPerLine = 60; sl@0: // Could be increased to 75 characters for every encoded line if KDecodeLineLength = 675. sl@0: // 60 was chosen to maintain existing behaviour. sl@0: const TInt8 KImcvLookUpStartOffset = 43; sl@0: const TUint8 KImcvConvEquals = '='; sl@0: const TInt8 AsciiToBase64[80]= sl@0: { sl@0: 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, sl@0: 57, 58, 59, 60, 61, -1, -1, -1, 64, -1, sl@0: -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, sl@0: 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, sl@0: 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, sl@0: -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, sl@0: 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, sl@0: 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 sl@0: }; sl@0: const TInt8 Base64ToAscii[65]= sl@0: { sl@0: 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, sl@0: 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, sl@0: 85, 86, 87, 88, 89, 90, 97, 98, 99,100, sl@0: 101,102,103,104,105,106,107,108,109,110, sl@0: 111,112,113,114,115,116,117,118,119,120, sl@0: 121,122, 48, 49, 50, 51, 52, 53, 54, 55, sl@0: 56, 57, 43, 47, 61 sl@0: }; sl@0: sl@0: /** sl@0: Base64 encoding and decoding class. sl@0: @internalAll sl@0: @released sl@0: */ sl@0: class TBase64 sl@0: { sl@0: private: sl@0: /** sl@0: enum base64 coding defines sl@0: */ sl@0: enum sl@0: { sl@0: /** Padding characters */ sl@0: EPadChar = 64 sl@0: }; sl@0: sl@0: /** sl@0: enum for EMaskValues sl@0: */ sl@0: enum EMaskValues sl@0: { sl@0: /** Mask Six bits */ sl@0: ESixBitMask = 0x3F, sl@0: /** Mask Eight bits */ sl@0: EEightBitMask = 0xFF sl@0: }; sl@0: sl@0: /** sl@0: enum for EMaskShiftValues sl@0: */ sl@0: enum EMaskShiftValues sl@0: { sl@0: /** enum for 6 */ sl@0: ESix = 6, sl@0: /** enum for 4 */ sl@0: EFour = 4, sl@0: /** enum for 2 */ sl@0: ETwo = 2, sl@0: /** enum for 0 */ sl@0: EZero = 0 sl@0: }; sl@0: sl@0: public: sl@0: IMPORT_C TBase64(); sl@0: IMPORT_C TInt Encode( const TDesC8& aSrcString, TDes8& rDestString); sl@0: IMPORT_C TBool Decode( const TDesC8& aSrcString, TDes8& rDestString); sl@0: IMPORT_C TInt PortableEncode(const TDesC8& aSrcString, TDes8& aDestString, TInt aLineLength=-1); sl@0: private: sl@0: sl@0: TInt iShiftStored; sl@0: TInt iMaskShiftStored; sl@0: }; sl@0: sl@0: #endif // __TCONVBASE64_H__