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

Botan 1.10.17

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