summaryrefslogtreecommitdiff
path: root/base64.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2015-11-22 19:17:15 -0500
committerJeffrey Walton <noloader@gmail.com>2015-11-22 19:17:15 -0500
commit298988a5b9687f64de733ce01319e90e94b0b688 (patch)
tree8b026ad4838457e3e5385ff91380ead4499d30f5 /base64.h
parent62618fda97bbde6d4cc4752101e69839fc4f3b6f (diff)
downloadcryptopp-git-298988a5b9687f64de733ce01319e90e94b0b688.tar.gz
Crypto++ 5.6.3 check-inCRYPTOPP_5_6_3
Diffstat (limited to 'base64.h')
-rw-r--r--base64.h59
1 files changed, 56 insertions, 3 deletions
diff --git a/base64.h b/base64.h
index 0f957f32..0a6d7768 100644
--- a/base64.h
+++ b/base64.h
@@ -1,6 +1,6 @@
// base64.h - written and placed in the public domain by Wei Dai
-//! \file
+//! \file base64.h
//! \brief Classes for the Base64Encoder, Base64Decoder, Base64URLEncoder and Base64URLDecoder
#ifndef CRYPTOPP_BASE64_H
@@ -18,12 +18,30 @@ NAMESPACE_BEGIN(CryptoPP)
class Base64Encoder : public SimpleProxyFilter
{
public:
+ //! \brief Construct a Base64Encoder
+ //! \param attachment a BufferedTrasformation to attach to this object
+ //! \param insertLineBreaks a BufferedTrasformation to attach to this object
+ //! \param maxLineLength the lenght of a line if line breaks are used
+ //! \details Base64Encoder() constructs a default encoder. The constructor lacks parameters for padding.
+ //! You must use IsolatedInitialize() to modify the Base64Encoder after construction.
+ //! \sa IsolatedInitialize() for an example of modifying a Base64Encoder after construction.
Base64Encoder(BufferedTransformation *attachment = NULL, bool insertLineBreaks = true, int maxLineLength = 72)
: SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment)
{
IsolatedInitialize(MakeParameters(Name::InsertLineBreaks(), insertLineBreaks)(Name::MaxLineLength(), maxLineLength));
}
-
+
+ //! \brief Initialize or reinitialize this object, without signal propagation
+ //! \param parameters a set of NameValuePairs used to initialize this object
+ //! \details IsolatedInitialize() is used to initialize or reinitialize an object using a variable
+ //! number of arbitrarily typed arguments. IsolatedInitialize() does not call Initialize() on attached
+ //! transformations. If initialization should be propagated, then use the Initialize() function.
+ //! \details The following code modifies the padding and line break parameters for an encoder:
+ //! <pre>
+ //! Base64Encoder encoder;
+ //! AlgorithmParameters params = MakeParameters(Pad(), false)(InsertLineBreaks(), false);
+ //! encoder.IsolatedInitialize(params);
+ //! </pre>
void IsolatedInitialize(const NameValuePairs &parameters);
};
@@ -34,9 +52,16 @@ public:
class Base64Decoder : public BaseN_Decoder
{
public:
+ //! \brief Construct a Base64Decoder
+ //! \param attachment a BufferedTrasformation to attach to this object
Base64Decoder(BufferedTransformation *attachment = NULL)
: BaseN_Decoder(GetDecodingLookupArray(), 6, attachment) {}
+ //! \brief Initialize or reinitialize this object, without signal propagation
+ //! \param parameters a set of NameValuePairs used to initialize this object
+ //! \details IsolatedInitialize() is used to initialize or reinitialize an object using a variable
+ //! number of arbitrarily typed arguments. IsolatedInitialize() does not call Initialize() on
+ //! attached transformations. If initialization should be propagated, then use the Initialize() function.
void IsolatedInitialize(const NameValuePairs &parameters)
{CRYPTOPP_UNUSED(parameters);}
@@ -51,12 +76,33 @@ private:
class Base64URLEncoder : public SimpleProxyFilter
{
public:
+ //! \brief Construct a Base64URLEncoder
+ //! \param attachment a BufferedTrasformation to attach to this object
+ //! \param insertLineBreaks a BufferedTrasformation to attach to this object
+ //! \param maxLineLength the lenght of a line if line breaks are used
+ //! \details Base64URLEncoder() constructs a default encoder. The constructor ignores insertLineBreaks
+ //! and maxLineLength because the web and URL safe specifications don't use them. They are present
+ //! in the constructor for API compatibility with Base64Encoder (drop-in replacement). The
+ //! constructor also disables padding on the encoder for the same reason.
+ //! \details If you need line breaks or padding, then you must use IsolatedInitialize() to set them
+ //! after constructing a Base64URLEncoder.
+ //! \sa IsolatedInitialize() for an example of modifying a Base64URLEncoder after construction.
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));
+ CRYPTOPP_UNUSED(insertLineBreaks), CRYPTOPP_UNUSED(maxLineLength);
+ IsolatedInitialize(MakeParameters(Name::InsertLineBreaks(), false)(Name::MaxLineLength(), -1)(Name::Pad(),false));
}
+ //! \details IsolatedInitialize() is used to initialize or reinitialize an object using a variable
+ //! number of arbitrarily typed arguments. IsolatedInitialize() does not call Initialize() on attached
+ //! transformations. If initialization should be propagated, then use the Initialize() function.
+ //! \details The following code modifies the padding and line break parameters for an encoder:
+ //! <pre>
+ //! Base64URLEncoder encoder;
+ //! AlgorithmParameters params = MakeParameters(Name::Pad(), true)(Name::InsertLineBreaks(), true);
+ //! encoder.IsolatedInitialize(params);
+ //! </pre>
void IsolatedInitialize(const NameValuePairs &parameters);
};
@@ -67,9 +113,16 @@ public:
class Base64URLDecoder : public BaseN_Decoder
{
public:
+ //! \brief Construct a Base64URLDecoder
+ //! \param attachment a BufferedTrasformation to attach to this object
Base64URLDecoder(BufferedTransformation *attachment = NULL)
: BaseN_Decoder(GetDecodingLookupArray(), 6, attachment) {}
+ //! \brief Initialize or reinitialize this object, without signal propagation
+ //! \param parameters a set of NameValuePairs used to initialize this object
+ //! \details IsolatedInitialize() is used to initialize or reinitialize an object using a variable
+ //! number of arbitrarily typed arguments. IsolatedInitialize() does not call Initialize() on
+ //! attached transformations. If initialization should be propagated, then use the Initialize() function.
void IsolatedInitialize(const NameValuePairs &parameters)
{CRYPTOPP_UNUSED(parameters);}