summaryrefslogtreecommitdiff
path: root/3rdParty/libb64/include/b64/encode.h
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-04-22 13:33:09 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2015-04-22 13:33:09 +0200
commitdec1359e90e847c90629e43ef3744539e8fb41c8 (patch)
treeda2d2ea07745c4eff127e4c62113e5f197dbc8c1 /3rdParty/libb64/include/b64/encode.h
parentd6e6f65a1cf8723a398689b549dd970121655053 (diff)
downloadaCms-dec1359e90e847c90629e43ef3744539e8fb41c8.tar.gz
aCms-dec1359e90e847c90629e43ef3744539e8fb41c8.tar.bz2
added base64 coding/decoding libary
showing captcha in login page (not verifying yet)
Diffstat (limited to '3rdParty/libb64/include/b64/encode.h')
-rw-r--r--3rdParty/libb64/include/b64/encode.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/3rdParty/libb64/include/b64/encode.h b/3rdParty/libb64/include/b64/encode.h
new file mode 100644
index 0000000..5d807d9
--- /dev/null
+++ b/3rdParty/libb64/include/b64/encode.h
@@ -0,0 +1,77 @@
+// :mode=c++:
+/*
+encode.h - c++ wrapper for a base64 encoding algorithm
+
+This is part of the libb64 project, and has been placed in the public domain.
+For details, see http://sourceforge.net/projects/libb64
+*/
+#ifndef BASE64_ENCODE_H
+#define BASE64_ENCODE_H
+
+#include <iostream>
+
+namespace base64
+{
+ extern "C"
+ {
+ #include "cencode.h"
+ }
+
+ struct encoder
+ {
+ base64_encodestate _state;
+ int _buffersize;
+
+ encoder(int buffersize_in = BUFFERSIZE)
+ : _buffersize(buffersize_in)
+ {}
+
+ int encode(char value_in)
+ {
+ return base64_encode_value(value_in);
+ }
+
+ int encode(const char* code_in, const int length_in, char* plaintext_out)
+ {
+ return base64_encode_block(code_in, length_in, plaintext_out, &_state);
+ }
+
+ int encode_end(char* plaintext_out)
+ {
+ return base64_encode_blockend(plaintext_out, &_state);
+ }
+
+ void encode(std::istream& istream_in, std::ostream& ostream_in)
+ {
+ base64_init_encodestate(&_state);
+ //
+ const int N = _buffersize;
+ char* plaintext = new char[N];
+ char* code = new char[2*N];
+ int plainlength;
+ int codelength;
+
+ do
+ {
+ istream_in.read(plaintext, N);
+ plainlength = istream_in.gcount();
+ //
+ codelength = encode(plaintext, plainlength, code);
+ ostream_in.write(code, codelength);
+ }
+ while (istream_in.good() && plainlength > 0);
+
+ codelength = encode_end(code);
+ ostream_in.write(code, codelength);
+ //
+ base64_init_encodestate(&_state);
+
+ delete [] code;
+ delete [] plaintext;
+ }
+ };
+
+} // namespace base64
+
+#endif // BASE64_ENCODE_H
+