1 /** \file Base64.h 2 ** \date 2004-02-13 3 ** \author grymse@alhem.net 4 **/ 5 /* 6 Copyright (C) 2004-2011 Anders Hedstrom 7 8 This library is made available under the terms of the GNU GPL, with 9 the additional exemption that compiling, linking, and/or using OpenSSL 10 is allowed. 11 12 If you would like to use this library in a closed-source application, 13 a separate license agreement is available. For information about 14 the closed-source license agreement for the C++ sockets library, 15 please visit http://www.alhem.net/Sockets/license.html and/or 16 email license@alhem.net. 17 18 This program is free software; you can redistribute it and/or 19 modify it under the terms of the GNU General Public License 20 as published by the Free Software Foundation; either version 2 21 of the License, or (at your option) any later version. 22 23 This program is distributed in the hope that it will be useful, 24 but WITHOUT ANY WARRANTY; without even the implied warranty of 25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 GNU General Public License for more details. 27 28 You should have received a copy of the GNU General Public License 29 along with this program; if not, write to the Free Software 30 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 31 */ 32 #ifndef _SOCKETS_Base64_H 33 #define _SOCKETS_Base64_H 34 35 #include "sockets-config.h" 36 #ifdef _MSC_VER 37 #pragma warning(disable:4514) 38 #endif 39 40 #include <stdio.h> 41 #include <string> 42 43 #ifdef SOCKETS_NAMESPACE 44 namespace SOCKETS_NAMESPACE { 45 #endif 46 47 class IFile; 48 49 /** \defgroup util Utilities */ 50 51 /** Base64 encode/decode. 52 \ingroup util */ 53 class Base64 54 { 55 public: 56 Base64(); 57 58 void encode(FILE *, std::string& , bool add_crlf = true); 59 void encode(IFile *, std::string& , bool add_crlf = true); 60 void encode(const std::string&, std::string& , bool add_crlf = true); 61 void encode(const char *, size_t, std::string& , bool add_crlf = true); 62 void encode(const unsigned char *, size_t, std::string& , bool add_crlf = true); 63 64 void decode(const std::string&, std::string& ); 65 void decode(const std::string&, unsigned char *, size_t&); 66 67 size_t decode_length(const std::string& ); 68 69 private: Base64(const Base64 &)70 Base64(const Base64& ) {} 71 Base64& operator=(const Base64& ) { return *this; } 72 static const char *bstr; 73 static const char rstr[128]; 74 }; 75 76 77 #ifdef SOCKETS_NAMESPACE 78 } 79 #endif 80 81 #endif // _SOCKETS_Base64_H 82 83