summaryrefslogtreecommitdiff
path: root/base64.cpp
diff options
context:
space:
mode:
authorweidai <weidai11@users.noreply.github.com>2002-10-04 17:31:41 +0000
committerweidai <weidai11@users.noreply.github.com>2002-10-04 17:31:41 +0000
commita3b6ece7ab341b5b14135baeccea7d5e4c086771 (patch)
tree8b045309c238226c32a563b1df6b9c30a2f0e0b3 /base64.cpp
downloadcryptopp-git-a3b6ece7ab341b5b14135baeccea7d5e4c086771.tar.gz
Initial revision
Diffstat (limited to 'base64.cpp')
-rw-r--r--base64.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/base64.cpp b/base64.cpp
new file mode 100644
index 00000000..0cc48b96
--- /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 &parameters)
+{
+ 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