NptBase64.h

00001 /*****************************************************************
00002 |
00003 |   Neptune - Base64
00004 |
00005 |   (c) 2001-2006 Gilles Boccon-Gibod
00006 |   Author: Gilles Boccon-Gibod (bok@bok.net)
00007 |
00008 ****************************************************************/
00009 
00010 #ifndef _NPT_BASE64_H_
00011 #define _NPT_BASE64_H_
00012 
00013 /*----------------------------------------------------------------------
00014 |   includes
00015 +---------------------------------------------------------------------*/
00016 #include "NptDataBuffer.h"
00017 #include "NptStrings.h"
00018 
00019 /*----------------------------------------------------------------------
00020 |   constants
00021 +---------------------------------------------------------------------*/
00022 const NPT_Cardinal NPT_BASE64_MIME_BLOCKS_PER_LINE = 19;
00023 const NPT_Cardinal NPT_BASE64_PEM_BLOCKS_PER_LINE  = 16;
00024 
00025 /*----------------------------------------------------------------------
00026 |   NPT_Base64
00027 +---------------------------------------------------------------------*/
00028 class NPT_Base64 {
00029 public:
00030     // class methods
00031     static NPT_Result Decode(const char*     base64, 
00032                              NPT_Size        size,
00033                              NPT_DataBuffer& data,
00034                              bool            url_safe = false);
00035     static NPT_Result Encode(const NPT_Byte* data, 
00036                              NPT_Size        size, 
00037                              NPT_String&     base64, 
00038                              NPT_Cardinal    max_blocks_per_line = 0, 
00039                              bool            url_safe = false);
00040 
00041 private: 
00042     // this class is purely static
00043     NPT_Base64();
00044 };
00045 
00046 #endif // _NPT_BASE64_H_