- Main Page
- Namespaces
- Classes
- Files

# 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(Name::InsertLineBreaks(), true);
    00015         int maxLineLength = parameters.GetIntValueWithDefault(Name::MaxLineLength(), 72);
    00016
    00017         const char *lineBreak = insertLineBreaks ? "\n" : "";
    00018
    00019         m_filter->Initialize(CombinedNameValuePairs(
    00020                 parameters,
    00021                 MakeParameters(Name::EncodingLookupArray(), &s_vec[0], false)
    00022                         (Name::PaddingByte(), s_padding)
    00023                         (Name::GroupSize(), insertLineBreaks ? maxLineLength : 0)
    00024                         (Name::Separator(), ConstByteArrayParameter(lineBreak))
    00025                         (Name::Terminator(), ConstByteArrayParameter(lineBreak))
    00026                         (Name::Log2Base(), 6, true)));
    00027 }
    00028
    00029 const int *Base64Decoder::GetDecodingLookupArray()
    00030 {
    00031         static bool s_initialized = false;
    00032         static int s_array[256];
    00033
    00034         if (!s_initialized)
    00035         {
    00036                 InitializeDecodingLookupArray(s_array, s_vec, 64, false);
    00037                 s_initialized = true;
    00038         }
    00039         return s_array;
    00040 }
    00041
    00042 NAMESPACE_END