hex.h
Go to the documentation of this file.
// hex.h - 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)
//! \class HexEncoder
//! \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 = NULL, 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);
};
//! \class HexDecoder
//! \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 = NULL)
: 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:554
HexDecoder
Decode base 16 data back to bytes.
Definition: hex.h:36
HexEncoder
Converts given data to base 16.
Definition: hex.h:16
BufferedTransformation
Interface for buffered transformations.
Definition: cryptlib.h:1352
SimpleProxyFilter
Proxy filter that doesn't modify the underlying filter's input or output.
Definition: filters.h:909
Grouper
Filter that breaks input stream into groups of fixed size.
Definition: basecode.h:110
basecode.h
Base classes for working with encoders and decoders.
BaseN_Encoder
Encoder for bases that are a power of 2.
Definition: basecode.h:18
BaseN_Decoder::IsolatedInitialize
void IsolatedInitialize(const NameValuePairs &parameters)
Initialize or reinitialize this object, without signal propagation.
Definition: basecode.cpp:115
HexDecoder::HexDecoder
HexDecoder(BufferedTransformation *attachment=NULL)
Construct a HexDecoder.
Definition: hex.h:41
CryptoPP
Crypto++ library namespace.
BaseN_Decoder
Decoder for bases that are a power of 2.
Definition: basecode.h:58
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:25
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:277
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:29