Botan: src/codec/base64/base64.h Source File

Botan 1.10.17

base64.h
Go to the documentation of this file.
1 /*
2 * Base64 Encoding and Decoding
3 * (C) 2010 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_BASE64_CODEC_H__
9 #define BOTAN_BASE64_CODEC_H__
10
11 #include <botan/secmem.h>
12 #include <string>
13
14 namespace Botan {
15
16 /**
17 * Perform base64 encoding
18 * @param output an array of at least input_length*4/3 bytes
19 * @param input is some binary data
20 * @param input_length length of input in bytes
21 * @param input_consumed is an output parameter which says how many
22 * bytes of input were actually consumed. If less than
23 * input_length, then the range input[consumed:length]
24 * should be passed in later along with more input.
25 * @param final_inputs true iff this is the last input, in which case
26 padding chars will be applied if needed
27 * @return number of bytes written to output
28 */
29 size_t BOTAN_DLL base64_encode(char output[],
30 const byte input[],
31 size_t input_length,
32 size_t& input_consumed,
33 bool final_inputs);
34
35 /**
36 * Perform base64 encoding
37 * @param input some input
38 * @param input_length length of input in bytes
39 * @return base64adecimal representation of input
40 */
41 std::string BOTAN_DLL base64_encode(const byte input[],
42 size_t input_length);
43
44 /**
45 * Perform base64 encoding
46 * @param input some input
47 * @return base64adecimal representation of input
48 */
49 std::string BOTAN_DLL base64_encode(const MemoryRegion<byte>& input);
50
51 /**
52 * Perform base64 decoding
53 * @param output an array of at least input_length*3/4 bytes
54 * @param input some base64 input
55 * @param input_length length of input in bytes
56 * @param input_consumed is an output parameter which says how many
57 * bytes of input were actually consumed. If less than
58 * input_length, then the range input[consumed:length]
59 * should be passed in later along with more input.
60 * @param final_inputs true iff this is the last input, in which case
61 padding is allowed
62 * @param ignore_ws ignore whitespace on input; if false, throw an
63 exception if whitespace is encountered
64 * @return number of bytes written to output
65 */
66 size_t BOTAN_DLL base64_decode(byte output[],
67 const char input[],
68 size_t input_length,
69 size_t& input_consumed,
70 bool final_inputs,
71 bool ignore_ws = true);
72
73 /**
74 * Perform base64 decoding
75 * @param output an array of at least input_length*3/4 bytes
76 * @param input some base64 input
77 * @param input_length length of input in bytes
78 * @param ignore_ws ignore whitespace on input; if false, throw an
79 exception if whitespace is encountered
80 * @return number of bytes written to output
81 */
82 size_t BOTAN_DLL base64_decode(byte output[],
83 const char input[],
84 size_t input_length,
85 bool ignore_ws = true);
86
87 /**
88 * Perform base64 decoding
89 * @param output an array of at least input_length/3*4 bytes
90 * @param input some base64 input
91 * @param ignore_ws ignore whitespace on input; if false, throw an
92 exception if whitespace is encountered
93 * @return number of bytes written to output
94 */
95 size_t BOTAN_DLL base64_decode(byte output[],
96 const std::string& input,
97 bool ignore_ws = true);
98
99 /**
100 * Perform base64 decoding
101 * @param input some base64 input
102 * @param input_length the length of input in bytes
103 * @param ignore_ws ignore whitespace on input; if false, throw an
104 exception if whitespace is encountered
105 * @return decoded base64 output
106 */
107 SecureVector<byte> BOTAN_DLL base64_decode(const char input[],
108 size_t input_length,
109 bool ignore_ws = true);
110
111 /**
112 * Perform base64 decoding
113 * @param input some base64 input
114 * @param ignore_ws ignore whitespace on input; if false, throw an
115 exception if whitespace is encountered
116 * @return decoded base64 output
117 */
118 SecureVector<byte> BOTAN_DLL base64_decode(const std::string& input,
119 bool ignore_ws = true);
120
121 }
122
123 #endif
Botan::base64_decode
size_t base64_decode(byte output[], const char input[], size_t input_length, size_t &input_consumed, bool final_inputs, bool ignore_ws)
Definition: base64.cpp:100
Botan::byte
unsigned char byte
Definition: types.h:22
Botan
Definition: algo_base.h:14
Botan::base64_encode
size_t base64_encode(char out[], const byte in[], size_t input_length, size_t &input_consumed, bool final_inputs)
Definition: base64.cpp:36