Botan 1.10.17
hex_filt.h
Go to the documentation of this file.
1/*
2* Hex Encoder/Decoder
3* (C) 1999-2010 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#ifndef BOTAN_HEX_FILTER_H__
9#define BOTAN_HEX_FILTER_H__
10
11#include <botan/filter.h>
12
13namespace Botan {
14
15/**
16* Converts arbitrary binary data to hex strings, optionally with
17* newlines inserted
18*/
19class BOTAN_DLL Hex_Encoder : public Filter
20 {
21 public:
22 /**
23 * Whether to use uppercase or lowercase letters for the encoded string.
24 */
26
27 std::string name() const { return "Hex_Encoder"; }
28
29 void write(const byte in[], size_t length);
30 void end_msg();
31
32 /**
33 * Create a hex encoder.
34 * @param the_case the case to use in the encoded strings.
35 */
36 Hex_Encoder(Case the_case);
37
38 /**
39 * Create a hex encoder.
40 * @param newlines should newlines be used
41 * @param line_length if newlines are used, how long are lines
42 * @param the_case the case to use in the encoded strings
43 */
44 Hex_Encoder(bool newlines = false,
45 size_t line_length = 72,
46 Case the_case = Uppercase);
47 private:
48 void encode_and_send(const byte[], size_t);
49
50 const Case casing;
51 const size_t line_length;
52 MemoryVector<byte> in, out;
53 size_t position, counter;
54 };
55
56/**
57* Converts hex strings to bytes
58*/
59class BOTAN_DLL Hex_Decoder : public Filter
60 {
61 public:
62 std::string name() const { return "Hex_Decoder"; }
63
64 void write(const byte[], size_t);
65 void end_msg();
66
67 /**
68 * Construct a Hex Decoder using the specified
69 * character checking.
70 * @param checking the checking to use during decoding.
71 */
73 private:
74 const Decoder_Checking checking;
75 MemoryVector<byte> in, out;
76 size_t position;
77 };
78
79}
80
81#endif
Hex_Decoder(Decoder_Checking checking=NONE)
Definition hex_filt.cpp:110
std::string name() const
Definition hex_filt.h:62
std::string name() const
Definition hex_filt.h:27
Hex_Encoder(Case the_case)
Definition hex_filt.cpp:36
Decoder_Checking
Definition filter.h:155
@ NONE
Definition filter.h:155