Botan 1.10.17

b64_filt.h
Go to the documentation of this file.
1 /*
2 * Base64 Encoder/Decoder
3 * (C) 1999-2010 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_BASE64_FILTER_H__
9 #define BOTAN_BASE64_FILTER_H__
10
11 #include <botan/filter.h>
12
13 namespace Botan {
14
15 /**
16 * This class represents a Base64 encoder.
17 */
18 class BOTAN_DLL Base64_Encoder : public Filter
19 {
20 public:
21 std::string name() const { return "Base64_Encoder"; }
22
23 /**
24 * Input a part of a message to the encoder.
25 * @param input the message to input as a byte array
26 * @param length the length of the byte array input
27 */
28 void write(const byte input[], size_t length);
29
30 /**
31 * Inform the Encoder that the current message shall be closed.
32 */
33 void end_msg();
34
35 /**
36 * Create a base64 encoder.
37 * @param breaks whether to use line breaks in the output
38 * @param length the length of the lines of the output
39 * @param t_n whether to use a trailing newline
40 */
41 Base64_Encoder(bool breaks = false, size_t length = 72,
42 bool t_n = false);
43 private:
44 void encode_and_send(const byte input[], size_t length,
45 bool final_inputs = false);
46 void do_output(const byte output[], size_t length);
47
48 const size_t line_length;
49 const bool trailing_newline;
50 MemoryVector<byte> in, out;
51 size_t position, out_position;
52 };
53
54 /**
55 * This object represents a Base64 decoder.
56 */
57 class BOTAN_DLL Base64_Decoder : public Filter
58 {
59 public:
60 std::string name() const { return "Base64_Decoder"; }
61
62 /**
63 * Input a part of a message to the decoder.
64 * @param input the message to input as a byte array
65 * @param length the length of the byte array input
66 */
67 void write(const byte input[], size_t length);
68
69 /**
70 * Finish up the current message
71 */
72 void end_msg();
73
74 /**
75 * Create a base64 decoder.
76 * @param checking the type of checking that shall be performed by
77 * the decoder
78 */
79 Base64_Decoder(Decoder_Checking checking = NONE);
80 private:
81 const Decoder_Checking checking;
82 MemoryVector<byte> in, out;
83 size_t position;
84 };
85
86 }
87
88 #endif
Botan::Base64_Encoder::name
std::string name() const
Definition: b64_filt.h:21
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::Base64_Decoder::name
std::string name() const
Definition: b64_filt.h:60
Botan::Filter
Definition: filter.h:19
Botan::Base64_Decoder
Definition: b64_filt.h:57
Botan::Base64_Encoder
Definition: b64_filt.h:18
Botan
Definition: algo_base.h:14
Botan::MemoryVector< byte >
Botan::NONE
Definition: filter.h:155
Botan::Decoder_Checking
Decoder_Checking
Definition: filter.h:155