Crypto++ 8.4 Free C++ class library of cryptographic schemes

hex.h
Go to the documentation of this file.
1 // hex.h - originally 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
12 NAMESPACE_BEGIN(CryptoPP)
13
14 /// \brief Converts given data to base 16
15 class CRYPTOPP_DLL HexEncoder : public SimpleProxyFilter
16 {
17 public:
18 /// \brief Construct a HexEncoder
19 /// \param attachment a BufferedTrasformation to attach to this object
20 /// \param uppercase a flag indicating uppercase output
21 /// \param groupSize the size of the output grouping
22 /// \param separator the separator to use between groups
23 /// \param terminator the terminator append after processing
24 HexEncoder(BufferedTransformation *attachment = NULLPTR, bool uppercase = true, int groupSize = 0, const std::string &separator = ":", const std::string &terminator = "")
25 : SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment)
26 {
27 IsolatedInitialize(MakeParameters(Name::Uppercase(), uppercase)(Name::GroupSize(), groupSize)(Name::Separator(), ConstByteArrayParameter(separator))(Name::Terminator(), ConstByteArrayParameter(terminator)));
28 }
29
30 void IsolatedInitialize(const NameValuePairs &parameters);
31 };
32
33 /// \brief Decode base 16 data back to bytes
34 class CRYPTOPP_DLL HexDecoder : public BaseN_Decoder
35 {
36 public:
37 /// \brief Construct a HexDecoder
38 /// \param attachment a BufferedTrasformation to attach to this object
39 HexDecoder(BufferedTransformation *attachment = NULLPTR)
40 : BaseN_Decoder(GetDefaultDecodingLookupArray(), 4, attachment) {}
41
42 void IsolatedInitialize(const NameValuePairs &parameters);
43
44 private:
45 static const int * CRYPTOPP_API GetDefaultDecodingLookupArray();
46 };
47
48 NAMESPACE_END
49
50 #endif
MakeParameters
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Definition: algparam.h:508
HexDecoder
Decode base 16 data back to bytes.
Definition: hex.h:34
HexEncoder
Converts given data to base 16.
Definition: hex.h:15
BufferedTransformation
Interface for buffered transformations.
Definition: cryptlib.h:1634
SimpleProxyFilter
Proxy filter that doesn't modify the underlying filter's input or output.
Definition: filters.h:1064
Grouper
Filter that breaks input stream into groups of fixed size.
Definition: basecode.h:112
basecode.h
Base classes for working with encoders and decoders.
BaseN_Encoder
Encoder for bases that are a power of 2.
Definition: basecode.h:17
BaseN_Decoder::IsolatedInitialize
void IsolatedInitialize(const NameValuePairs &parameters)
Initialize or reinitialize this object, without signal propagation.
HexDecoder::HexDecoder
HexDecoder(BufferedTransformation *attachment=NULL)
Construct a HexDecoder.
Definition: hex.h:39
CryptoPP
Crypto++ library namespace.
BaseN_Decoder
Decoder for bases that are a power of 2.
Definition: basecode.h:58
CRYPTOPP_API
#define CRYPTOPP_API
Win32 calling convention.
Definition: config_dll.h:119
HexEncoder::HexEncoder
HexEncoder(BufferedTransformation *attachment=NULL, bool uppercase=true, int groupSize=0, const std::string &separator=":", const std::string &terminator="")
Construct a HexEncoder.
Definition: hex.h:24
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:321
cryptlib.h
Abstract base classes that provide a uniform interface to this library.
ConstByteArrayParameter
Used to pass byte array input as part of a NameValuePairs object.
Definition: algparam.h:24