Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:03

0001 // hex.h - originally written and placed in the public domain by Wei Dai

0002 
0003 /// \file hex.h

0004 /// \brief Classes for HexEncoder and HexDecoder

0005 
0006 #ifndef CRYPTOPP_HEX_H
0007 #define CRYPTOPP_HEX_H
0008 
0009 #include "cryptlib.h"
0010 #include "basecode.h"
0011 
0012 NAMESPACE_BEGIN(CryptoPP)
0013 
0014 /// \brief Converts given data to base 16

0015 class CRYPTOPP_DLL HexEncoder : public SimpleProxyFilter
0016 {
0017 public:
0018     /// \brief Construct a HexEncoder

0019     /// \param attachment a BufferedTrasformation to attach to this object

0020     /// \param uppercase a flag indicating uppercase output

0021     /// \param groupSize the size of the output grouping

0022     /// \param separator the separator to use between groups

0023     /// \param terminator the terminator append after processing

0024     HexEncoder(BufferedTransformation *attachment = NULLPTR, bool uppercase = true, int groupSize = 0, const std::string &separator = ":", const std::string &terminator = "")
0025         : SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment)
0026     {
0027         IsolatedInitialize(MakeParameters(Name::Uppercase(), uppercase)(Name::GroupSize(), groupSize)(Name::Separator(), ConstByteArrayParameter(separator))(Name::Terminator(), ConstByteArrayParameter(terminator)));
0028     }
0029 
0030     void IsolatedInitialize(const NameValuePairs &parameters);
0031 };
0032 
0033 /// \brief Decode base 16 data back to bytes

0034 class CRYPTOPP_DLL HexDecoder : public BaseN_Decoder
0035 {
0036 public:
0037     /// \brief Construct a HexDecoder

0038     /// \param attachment a BufferedTrasformation to attach to this object

0039     HexDecoder(BufferedTransformation *attachment = NULLPTR)
0040         : BaseN_Decoder(GetDefaultDecodingLookupArray(), 4, attachment) {}
0041 
0042     void IsolatedInitialize(const NameValuePairs &parameters);
0043 
0044 private:
0045     static const int * CRYPTOPP_API GetDefaultDecodingLookupArray();
0046 };
0047 
0048 NAMESPACE_END
0049 
0050 #endif