source: git/src-cryptopp/hex.h

Last change on this file was e230cb0, checked in by David Stainton <dstainton415@…>, at 2016-10-12T13:27:29Z

Add cryptopp from tag CRYPTOPP_5_6_5

  • Property mode set to 100644
File size: 1.8 KB
Line 
1// hex.h - written and placed in the public domain by Wei Dai
2
3//! \file hex.h
4//! \brief Classes for HexEncoder and HexDecoder
5
6#ifndef CRYPTOPP_HEX_H
7#define CRYPTOPP_HEX_H
8
9#include "cryptlib.h"
10#include "basecode.h"
11
12NAMESPACE_BEGIN(CryptoPP)
13
14//! \class HexEncoder
15//! \brief Converts given data to base 16
16class CRYPTOPP_DLL HexEncoder : public SimpleProxyFilter
17{
18public:
19        //! \brief Construct a HexEncoder
20        //! \param attachment a BufferedTrasformation to attach to this object
21        //! \param uppercase a flag indicating uppercase output
22        //! \param groupSize the size of the output grouping
23        //! \param separator the separator to use between groups
24        //! \param terminator the terminator append after processing
25        HexEncoder(BufferedTransformation *attachment = NULL, bool uppercase = true, int groupSize = 0, const std::string &separator = ":", const std::string &terminator = "")
26                : SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment)
27        {
28                IsolatedInitialize(MakeParameters(Name::Uppercase(), uppercase)(Name::GroupSize(), groupSize)(Name::Separator(), ConstByteArrayParameter(separator))(Name::Terminator(), ConstByteArrayParameter(terminator)));
29        }
30
31        void IsolatedInitialize(const NameValuePairs &parameters);
32};
33
34//! \class HexDecoder
35//! \brief Decode base 16 data back to bytes
36class CRYPTOPP_DLL HexDecoder : public BaseN_Decoder
37{
38public:
39        //! \brief Construct a HexDecoder
40        //! \param attachment a BufferedTrasformation to attach to this object
41        HexDecoder(BufferedTransformation *attachment = NULL)
42                : BaseN_Decoder(GetDefaultDecodingLookupArray(), 4, attachment) {}
43
44        void IsolatedInitialize(const NameValuePairs &parameters);
45
46private:
47        static const int * CRYPTOPP_API GetDefaultDecodingLookupArray();
48};
49
50NAMESPACE_END
51
52#endif
Note: See TracBrowser for help on using the repository browser.