From b21162cf8e06f40baa1f58be6a8c17435cebc34d Mon Sep 17 00:00:00 2001 From: weidai Date: Fri, 4 Oct 2002 17:31:41 +0000 Subject: Initial revision git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@2 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- basecode.h | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 basecode.h (limited to 'basecode.h') diff --git a/basecode.h b/basecode.h new file mode 100644 index 0000000..dcb49b0 --- /dev/null +++ b/basecode.h @@ -0,0 +1,82 @@ +#ifndef CRYPTOPP_BASECODE_H +#define CRYPTOPP_BASECODE_H + +#include "filters.h" +#include "algparam.h" + +NAMESPACE_BEGIN(CryptoPP) + +class BaseN_Encoder : public Unflushable +{ +public: + BaseN_Encoder(BufferedTransformation *attachment=NULL) + : Unflushable(attachment) {} + + BaseN_Encoder(const byte *alphabet, int log2base, BufferedTransformation *attachment=NULL, int padding=-1) + : Unflushable(attachment) + { + IsolatedInitialize(MakeParameters("EncodingLookupArray", alphabet) + ("Log2Base", log2base) + ("Pad", padding != -1) + ("PaddingByte", byte(padding))); + } + + void IsolatedInitialize(const NameValuePairs ¶meters); + unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking); + +private: + const byte *m_alphabet; + int m_padding, m_bitsPerChar, m_outputBlockSize; + int m_bytePos, m_bitPos; + SecByteBlock m_outBuf; +}; + +class BaseN_Decoder : public Unflushable +{ +public: + BaseN_Decoder(BufferedTransformation *attachment=NULL) + : Unflushable(attachment) {} + + BaseN_Decoder(const int *lookup, int log2base, BufferedTransformation *attachment=NULL) + : Unflushable(attachment) + { + IsolatedInitialize(MakeParameters("DecodingLookupArray", lookup)("Log2Base", log2base)); + } + + void IsolatedInitialize(const NameValuePairs ¶meters); + unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking); + + static void InitializeDecodingLookupArray(int *lookup, const byte *alphabet, unsigned int log2base, bool caseInsensitive); + +private: + const int *m_lookup; + int m_padding, m_bitsPerChar, m_outputBlockSize; + int m_bytePos, m_bitPos; + SecByteBlock m_outBuf; +}; + +class Grouper : public Bufferless +{ +public: + Grouper(BufferedTransformation *attachment=NULL) + : Bufferless(attachment) {} + + Grouper(int groupSize, const std::string &seperator, const std::string &terminator, BufferedTransformation *attachment=NULL) + : Bufferless(attachment) + { + IsolatedInitialize(MakeParameters("GroupSize", groupSize) + ("Seperator", ConstByteArrayParameter(seperator)) + ("Terminator", ConstByteArrayParameter(terminator))); + } + + void IsolatedInitialize(const NameValuePairs ¶meters); + unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking); + +private: + SecByteBlock m_seperator, m_terminator; + unsigned int m_groupSize, m_counter; +}; + +NAMESPACE_END + +#endif -- cgit v1.2.1