summaryrefslogtreecommitdiff
path: root/base64.h
diff options
context:
space:
mode:
authornoloader <noloader@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2015-07-02 00:58:24 +0000
committernoloader <noloader@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2015-07-02 00:58:24 +0000
commit1ae432917c9c194b71e8a5422ea17cdb608c3650 (patch)
tree0ca50109bc32db1240b626710c3f11126bea9802 /base64.h
parentb64fbd0bc3541e3b110da6ca80dfb38edb830a1e (diff)
downloadcryptopp-1ae432917c9c194b71e8a5422ea17cdb608c3650.tar.gz
Added Base64URLEncoder and decoder for web safe alphabet from RFC 4648, Section 5. Discussion at https://groups.google.com/d/msg/cryptopp-users/OF5RPXW-cHw/EDrOuA4-rRYJ
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@563 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'base64.h')
-rw-r--r--base64.h37
1 files changed, 33 insertions, 4 deletions
diff --git a/base64.h b/base64.h
index 5a9e184..428b62c 100644
--- a/base64.h
+++ b/base64.h
@@ -5,7 +5,8 @@
NAMESPACE_BEGIN(CryptoPP)
-//! Base64 Encoder Class
+//! Base64 Encoder Class
+// https://tools.ietf.org/html/rfc4648#section-4
class Base64Encoder : public SimpleProxyFilter
{
public:
@@ -14,19 +15,47 @@ public:
{
IsolatedInitialize(MakeParameters(Name::InsertLineBreaks(), insertLineBreaks)(Name::MaxLineLength(), maxLineLength));
}
-
+
void IsolatedInitialize(const NameValuePairs &parameters);
};
-//! Base64 Decoder Class
+//! Base64 Decoder Class
+// https://tools.ietf.org/html/rfc4648#section-4
class Base64Decoder : public BaseN_Decoder
{
public:
Base64Decoder(BufferedTransformation *attachment = NULL)
: BaseN_Decoder(GetDecodingLookupArray(), 6, attachment) {}
-
+
void IsolatedInitialize(const NameValuePairs &parameters) {}
+
+private:
+ static const int * CRYPTOPP_API GetDecodingLookupArray();
+};
+
+//! Base64 URL Encoder Class
+// https://tools.ietf.org/html/rfc4648#section-5
+class Base64URLEncoder : public SimpleProxyFilter
+{
+public:
+ Base64URLEncoder(BufferedTransformation *attachment = NULL, bool insertLineBreaks = false, int maxLineLength = -1)
+ : SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment)
+ {
+ IsolatedInitialize(MakeParameters(Name::InsertLineBreaks(), insertLineBreaks)(Name::MaxLineLength(), maxLineLength));
+ }
+
+ void IsolatedInitialize(const NameValuePairs &parameters);
+};
+//! Base64 URL Decoder Class
+class Base64URLDecoder : public BaseN_Decoder
+{
+public:
+ Base64URLDecoder(BufferedTransformation *attachment = NULL)
+ : BaseN_Decoder(GetDecodingLookupArray(), 6, attachment) {}
+
+ void IsolatedInitialize(const NameValuePairs &parameters) {}
+
private:
static const int * CRYPTOPP_API GetDecodingLookupArray();
};