monotone

monotone Mtn Source Tree

Root/cryptopp/base64.cpp

1// base64.cpp - written and placed in the public domain by Wei Dai
2
3#include "pch.h"
4#include "base64.h"
5
6NAMESPACE_BEGIN(CryptoPP)
7
8static const byte s_vec[] =
9"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
10static const byte s_padding = '=';
11
12void Base64Encoder::IsolatedInitialize(const NameValuePairs &parameters)
13{
14bool insertLineBreaks = parameters.GetValueWithDefault("InsertLineBreaks", true);
15int maxLineLength = parameters.GetIntValueWithDefault("MaxLineLength", 72);
16
17const char *lineBreak = insertLineBreaks ? "\n" : "";
18
19m_filter->Initialize(CombinedNameValuePairs(
20parameters,
21MakeParameters("EncodingLookupArray", (const byte *)s_vec)
22("PaddingByte", s_padding)
23("Log2Base", 6)
24("GroupSize", insertLineBreaks ? maxLineLength : 0)
25("Separator", ConstByteArrayParameter(lineBreak))
26("Terminator", ConstByteArrayParameter(lineBreak))));
27}
28
29const int *Base64Decoder::GetDecodingLookupArray()
30{
31static bool s_initialized = false;
32static int s_array[256];
33
34if (!s_initialized)
35{
36InitializeDecodingLookupArray(s_array, s_vec, 64, false);
37s_initialized = true;
38}
39return s_array;
40}
41
42NAMESPACE_END

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status