Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

basecode.h

00001 #ifndef CRYPTOPP_BASECODE_H
00002 #define CRYPTOPP_BASECODE_H
00003 
00004 #include "filters.h"
00005 #include "algparam.h"
00006 
00007 NAMESPACE_BEGIN(CryptoPP)
00008 
00009 class BaseN_Encoder : public Unflushable<Filter>
00010 {
00011 public:
00012         BaseN_Encoder(BufferedTransformation *attachment=NULL)
00013                 : Unflushable<Filter>(attachment) {}
00014 
00015         BaseN_Encoder(const byte *alphabet, int log2base, BufferedTransformation *attachment=NULL, int padding=-1)
00016                 : Unflushable<Filter>(attachment)
00017         {
00018                 IsolatedInitialize(MakeParameters("EncodingLookupArray", alphabet)
00019                         ("Log2Base", log2base)
00020                         ("Pad", padding != -1)
00021                         ("PaddingByte", byte(padding)));
00022         }
00023 
00024         void IsolatedInitialize(const NameValuePairs &parameters);
00025         unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking);
00026 
00027 private:
00028         const byte *m_alphabet;
00029         int m_padding, m_bitsPerChar, m_outputBlockSize;
00030         int m_bytePos, m_bitPos;
00031         SecByteBlock m_outBuf;
00032 };
00033 
00034 class BaseN_Decoder : public Unflushable<Filter>
00035 {
00036 public:
00037         BaseN_Decoder(BufferedTransformation *attachment=NULL)
00038                 : Unflushable<Filter>(attachment) {}
00039 
00040         BaseN_Decoder(const int *lookup, int log2base, BufferedTransformation *attachment=NULL)
00041                 : Unflushable<Filter>(attachment)
00042         {
00043                 IsolatedInitialize(MakeParameters("DecodingLookupArray", lookup)("Log2Base", log2base));
00044         }
00045 
00046         void IsolatedInitialize(const NameValuePairs &parameters);
00047         unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking);
00048 
00049         static void InitializeDecodingLookupArray(int *lookup, const byte *alphabet, unsigned int log2base, bool caseInsensitive);
00050 
00051 private:
00052         const int *m_lookup;
00053         int m_padding, m_bitsPerChar, m_outputBlockSize;
00054         int m_bytePos, m_bitPos;
00055         SecByteBlock m_outBuf;
00056 };
00057 
00058 class Grouper : public Bufferless<Filter>
00059 {
00060 public:
00061         Grouper(BufferedTransformation *attachment=NULL)
00062                 : Bufferless<Filter>(attachment) {}
00063 
00064         Grouper(int groupSize, const std::string &separator, const std::string &terminator, BufferedTransformation *attachment=NULL)
00065                 : Bufferless<Filter>(attachment)
00066         {
00067                 IsolatedInitialize(MakeParameters("GroupSize", groupSize)
00068                         ("Separator", ConstByteArrayParameter(separator))
00069                         ("Terminator", ConstByteArrayParameter(terminator)));
00070         }
00071 
00072         void IsolatedInitialize(const NameValuePairs &parameters);
00073         unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking);
00074 
00075 private:
00076         SecByteBlock m_separator, m_terminator;
00077         unsigned int m_groupSize, m_counter;
00078 };
00079 
00080 NAMESPACE_END
00081 
00082 #endif

Generated on Mon Apr 19 18:12:28 2004 for Crypto++ by doxygen 1.3.6-20040222