diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2002-10-04 17:31:41 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2002-10-04 17:31:41 +0000 |
commit | b21162cf8e06f40baa1f58be6a8c17435cebc34d (patch) | |
tree | 8b045309c238226c32a563b1df6b9c30a2f0e0b3 /base64.cpp | |
download | cryptopp-b21162cf8e06f40baa1f58be6a8c17435cebc34d.tar.gz |
Initial revision
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@2 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'base64.cpp')
-rw-r--r-- | base64.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/base64.cpp b/base64.cpp new file mode 100644 index 0000000..0cc48b9 --- /dev/null +++ b/base64.cpp @@ -0,0 +1,40 @@ +// base64.cpp - written and placed in the public domain by Wei Dai + +#include "pch.h" +#include "base64.h" + +NAMESPACE_BEGIN(CryptoPP) + +static const byte s_vec[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +static const byte s_padding = '='; + +void Base64Encoder::IsolatedInitialize(const NameValuePairs ¶meters) +{ + bool insertLineBreaks = parameters.GetValueWithDefault("InsertLineBreaks", true); + int maxLineLength = parameters.GetIntValueWithDefault("MaxLineLength", 72); + + m_filter->Initialize(CombinedNameValuePairs( + parameters, + MakeParameters("EncodingLookupArray", (const byte *)s_vec) + ("PaddingByte", s_padding) + ("Log2Base", 6) + ("GroupSize", insertLineBreaks ? maxLineLength : 0) + ("Seperator", ConstByteArrayParameter("\n")) + ("Terminator", ConstByteArrayParameter("\n")))); +} + +const int *Base64Decoder::GetDecodingLookupArray() +{ + static bool s_initialized = false; + static int s_array[256]; + + if (!s_initialized) + { + InitializeDecodingLookupArray(s_array, s_vec, 64, false); + s_initialized = true; + } + return s_array; +} + +NAMESPACE_END |