Botan

Hex Encoding and Decoding

License
Botan is released under the Simplified BSD License (see LICENSE.md)

void  hexEncode(char* output, const(ubyte)* input, size_t input_length, bool uppercase = true);

Perform hex encoding

Parameters
char* output an array of at least input_length*2 bytes
const(ubyte)* input is some binary data
size_t input_length length of input in bytes
bool uppercase should output be upper or lower case?

string  hexEncode(const(ubyte)* input, size_t input_length, bool uppercase = true);

Perform hex encoding

Parameters
const(ubyte)* input some input
size_t input_length length of input in bytes
bool uppercase should output be upper or lower case?
Returns
hexadecimal representation of input

string  hexEncode(Alloc)(auto ref const Vector!(ubyte, Alloc) input, bool uppercase = true);
string  hexEncode(Alloc)(auto ref const RefCounted!(Vector!(ubyte, Alloc), Alloc) input, bool uppercase = true);

Perform hex encoding

Parameters
Vector!(ubyte, Alloc) input some input
bool uppercase should output be upper or lower case?
Returns
hexadecimal representation of input

size_t  hexDecode(ubyte* output, const(char)* input, size_t input_length, ref size_t input_consumed, bool ignore_ws = true);

Perform hex decoding

Parameters
ubyte* output an array of at least input_length/2 bytes
const(char)* input some hex input
size_t input_length length of input in bytes
size_t input_consumed is an output parameter which says how many bytes of input were actually consumed. If less than input_length, then the range input[consumed:length] should be passed in later along with more input.
bool ignore_ws ignore whitespace on input; if false, throw new an exception if whitespace is encountered
Returns
number of bytes written to output

size_t  hexDecode(ubyte* output, const(char)* input, size_t input_length, bool ignore_ws = true);

Perform hex decoding

Parameters
ubyte* output an array of at least input_length/2 bytes
const(char)* input some hex input
size_t input_length length of input in bytes
bool ignore_ws ignore whitespace on input; if false, throw new an exception if whitespace is encountered
Returns
number of bytes written to output

size_t  hexDecode(ubyte* output, in string input, bool ignore_ws = true);

Perform hex decoding

Parameters
ubyte* output an array of at least input_length/2 bytes
string input some hex input
bool ignore_ws ignore whitespace on input; if false, throw new an exception if whitespace is encountered
Returns
number of bytes written to output

Vector!ubyte  hexDecode(string input, bool ignore_ws = true);

Perform hex decoding

Parameters
string input some hex input
bool ignore_ws ignore whitespace on input; if false, throw new an exception if whitespace is encountered
Returns
decoded hex output

Vector!ubyte  hexDecode(ref const Vector!ubyte input, bool ignore_ws = true);

Perform hex decoding

Parameters
Vector!ubyte input some hex input
bool ignore_ws ignore whitespace on input; if false, throw new an exception if whitespace is encountered
Returns
decoded hex output

SecureVector!ubyte  hexDecodeLocked(const(char)* input, size_t input_length, bool ignore_ws = true);

Perform hex decoding

Parameters
const(char)* input some hex input
size_t input_length the length of input in bytes
bool ignore_ws ignore whitespace on input; if false, throw new an exception if whitespace is encountered
Returns
decoded hex output

SecureVector!ubyte  hexDecodeLocked(in string input, bool ignore_ws = true);

Perform hex decoding

Parameters
string input some hex input
bool ignore_ws ignore whitespace on input; if false, throw new an exception if whitespace is encountered
Returns
decoded hex output