hex.h
Go to the documentation of this file.
// hex.h - originally written and placed in the public domain by Wei Dai
/// \file hex.h
/// \brief Classes for HexEncoder and HexDecoder
#ifndef CRYPTOPP_HEX_H
#define CRYPTOPP_HEX_H
#include "cryptlib.h"
#include "basecode.h"
NAMESPACE_BEGIN(CryptoPP)
/// \brief Converts given data to base 16
class CRYPTOPP_DLL HexEncoder : public SimpleProxyFilter
{
public:
/// \brief Construct a HexEncoder
/// \param attachment a BufferedTrasformation to attach to this object
/// \param uppercase a flag indicating uppercase output
/// \param groupSize the size of the output grouping
/// \param separator the separator to use between groups
/// \param terminator the terminator append after processing
HexEncoder(BufferedTransformation *attachment = NULLPTR, bool uppercase = true, int groupSize = 0, const std::string &separator = ":", const std::string &terminator = "")
: SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment)
{
IsolatedInitialize(MakeParameters(Name::Uppercase(), uppercase)(Name::GroupSize(), groupSize)(Name::Separator(), ConstByteArrayParameter(separator))(Name::Terminator(), ConstByteArrayParameter(terminator)));
}
void IsolatedInitialize(const NameValuePairs &parameters);
};
/// \brief Decode base 16 data back to bytes
class CRYPTOPP_DLL HexDecoder : public BaseN_Decoder
{
public:
/// \brief Construct a HexDecoder
/// \param attachment a BufferedTrasformation to attach to this object
HexDecoder(BufferedTransformation *attachment = NULLPTR)
: BaseN_Decoder(GetDefaultDecodingLookupArray(), 4, attachment) {}
void IsolatedInitialize(const NameValuePairs &parameters);
private:
static const int * CRYPTOPP_API GetDefaultDecodingLookupArray();
};
NAMESPACE_END
#endif
MakeParameters
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Definition algparam.h:508
basecode.h
Base classes for working with encoders and decoders.
BaseN_Decoder::BaseN_Decoder
BaseN_Decoder(BufferedTransformation *attachment=NULL)
Construct a BaseN_Decoder.
Definition basecode.h:65
BaseN_Encoder
Encoder for bases that are a power of 2.
Definition basecode.h:18
BufferedTransformation
Interface for buffered transformations.
Definition cryptlib.h:1657
ConstByteArrayParameter
Used to pass byte array input as part of a NameValuePairs object.
Definition algparam.h:25
Grouper
Filter that breaks input stream into groups of fixed size.
Definition basecode.h:113
HexDecoder::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
HexEncoder::IsolatedInitialize
void IsolatedInitialize(const NameValuePairs &parameters)
Initialize or reinitialize this object, without signal propagation.
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:327
SimpleProxyFilter::SimpleProxyFilter
SimpleProxyFilter(BufferedTransformation *filter, BufferedTransformation *attachment)
Construct a SimpleProxyFilter.
Definition filters.h:1070
CRYPTOPP_API
#define CRYPTOPP_API
Win32 calling convention.
Definition config_dll.h:119
cryptlib.h
Abstract base classes that provide a uniform interface to this library.
CryptoPP
Crypto++ library namespace.
Name::GroupSize
const char * GroupSize()
int
Definition argnames.h:71
Name::Uppercase
const char * Uppercase()
bool
Definition argnames.h:70
Name::Terminator
const char * Terminator()
ConstByteArrayParameter.
Definition argnames.h:69
Name::Separator
const char * Separator()
ConstByteArrayParameter.
Definition argnames.h:68