Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# base64.cpp

    00001 // base64.cpp - written and placed in the public domain by Wei Dai
    00002
    00003 #include "pch.h"
    00004 #include "base64.h"
    00005
    00006 NAMESPACE_BEGIN(CryptoPP)
    00007
    00008 static const byte s_vec[] =
    00009                 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    00010 static const byte s_padding = '=';
    00011
    00012 void Base64Encoder::IsolatedInitialize(const NameValuePairs &parameters)
    00013 {
    00014         bool insertLineBreaks = parameters.GetValueWithDefault("InsertLineBreaks", true);
    00015         int maxLineLength = parameters.GetIntValueWithDefault("MaxLineLength", 72);
    00016
    00017         m_filter->Initialize(CombinedNameValuePairs(
    00018                 parameters,
    00019                 MakeParameters("EncodingLookupArray", (const byte *)s_vec)
    00020                         ("PaddingByte", s_padding)
    00021                         ("Log2Base", 6)
    00022                         ("GroupSize", insertLineBreaks ? maxLineLength : 0)
    00023                         ("Seperator", ConstByteArrayParameter("\n"))
    00024                         ("Terminator", ConstByteArrayParameter("\n"))));
    00025 }
    00026
    00027 const int *Base64Decoder::GetDecodingLookupArray()
    00028 {
    00029         static bool s_initialized = false;
    00030         static int s_array[256];
    00031
    00032         if (!s_initialized)
    00033         {
    00034                 InitializeDecodingLookupArray(s_array, s_vec, 64, false);
    00035                 s_initialized = true;
    00036         }
    00037         return s_array;
    00038 }
    00039
    00040 NAMESPACE_END