Passenger: Base64.h Source File

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List

# Base64.h

    00001 /*
    00002  * Base64 encoding and decoding routines
    00003  *
    00004  * Copyright (C) 2004-2008 René Nyffenegger
    00005  * Modified by Phusion for inclusion in Phusion Passenger.
    00006  *
    00007  * This source code is provided 'as-is', without any express or implied
    00008  * warranty. In no event will the author be held liable for any damages
    00009  * arising from the use of this software.
    00010  *
    00011  * Permission is granted to anyone to use this software for any purpose,
    00012  * including commercial applications, and to alter it and redistribute it
    00013  * freely, subject to the following restrictions:
    00014  *
    00015  * 1. The origin of this source code must not be misrepresented; you must not
    00016  *    claim that you wrote the original source code. If you use this source code
    00017  *    in a product, an acknowledgment in the product documentation would be
    00018  *    appreciated but is not required.
    00019  *
    00020  * 2. Altered source versions must be plainly marked as such, and must not be
    00021  *    misrepresented as being the original source code.
    00022  *
    00023  * 3. This notice may not be removed or altered from any source distribution.
    00024  *
    00025  * René Nyffenegger rene.nyffenegger@adp-gmbh.ch
    00026  *
    00027  */
    00028
    00029 #ifndef _PASSENGER_BASE64_H_
    00030 #define _PASSENGER_BASE64_H_
    00031
    00032 #include <iostream>
    00033 #include <string>
    00034 #include "StaticString.h"
    00035
    00036 namespace Passenger {
    00037
    00038 using namespace std;
    00039
    00040 class Base64 {
    00041 public:
    00042         static string encode(const StaticString &data) {
    00043                 return encode((const unsigned char *) data.data(), data.size());
    00044         }
    00045
    00046         static string decode(const StaticString &base64_data) {
    00047                 return decode((const unsigned char *) base64_data.data(), base64_data.size());
    00048         }
    00049
    00050         static string encode(const unsigned char *data, unsigned int len);
    00051
    00052         static string decode(const unsigned char *base64_data, unsigned int len);
    00053 };
    00054
    00055 } // namespace Passenger
    00056
    00057 #endif /* _PASSENGER_BASE64_H_ */