Kea  2.1.7-git
isc::util::encode Namespace Reference

Namespaces

 clang_unnamed_namespace_workaround
 

Functions

void decodeBase32Hex (const std::string &input, std::vector< uint8_t > &result)
 Decode a text encoded in the base32hex format into the original data. More...
 
void decodeBase64 (const std::string &input, std::vector< uint8_t > &result)
 Decode a text encoded in the base64 format into the original data. More...
 
void decodeHex (const std::string &input, std::vector< uint8_t > &result)
 Decode a text encoded in the base16 ('hex') format into the original data. More...
 
std::string encodeBase32Hex (const std::vector< uint8_t > &binary)
 Encode binary data in the base32hex format. More...
 
std::string encodeBase64 (const std::vector< uint8_t > &binary)
 Encode binary data in the base64 format. More...
 
string encodeHex (const std::vector< uint8_t > &binary)
 Encode binary data in the base16 ('hex') format. More...
 
std::vector< uint8_t > encodeUtf8 (const std::string &value)
 Encode value string into UTF-8. More...
 
std::string toHex (std::string value)
 Encode in hexadecimal inline. More...
 

Function Documentation

◆ decodeBase32Hex()

void isc::util::encode::decodeBase32Hex ( const std::string &  input,
std::vector< uint8_t > &  result 
)

Decode a text encoded in the base32hex format into the original data.

The underlying implementation is shared with decodeBase64, and all description except the format (base32hex) equally applies.

Note: the encoding format is base32hex, not base32.

Parameters
inputA text encoded in the base32hex format.
resultA vector in which the decoded data is to be stored.

Definition at line 464 of file base_n.cc.

◆ decodeBase64()

void isc::util::encode::decodeBase64 ( const std::string &  input,
std::vector< uint8_t > &  result 
)

Decode a text encoded in the base64 format into the original data.

The input argument must be a valid string represented in the base64 format as specified in RFC4648. Space characters (spaces, tabs, newlines) can be included in input and will be ignored. Without spaces, the length of string must be a multiple of 4 bytes with necessary paddings. Also it must be encoded using the canonical encoding (see RFC4648). If any of these conditions is not met, an exception of class isc::BadValue will be thrown.

If result doesn't have sufficient capacity to store all decoded data and memory allocation fails, a corresponding standard exception will be thrown. If the caller knows the necessary length (which can in theory be calculated from the input string), this situation can be avoided by reserving sufficient space for result beforehand.

Any existing data in result will be removed. This is the case in some of the cases where an exception is thrown; that is, this function only provides the basic exception guarantee.

Parameters
inputA text encoded in the base64 format.
resultA vector in which the decoded data is to be stored.

Definition at line 454 of file base_n.cc.

Referenced by isc::dns::TSIGKey::TSIGKey().

◆ decodeHex()

void isc::util::encode::decodeHex ( const std::string &  input,
std::vector< uint8_t > &  result 
)

Decode a text encoded in the base16 ('hex') format into the original data.

The underlying implementation is shared with decodeBase64, and most of the description except the format (base16) equally applies. Another notable exception is that the base16 encoding doesn't require padding, so padding related considerations and the notion of canonical encoding don't apply.

Parameters
inputA text encoded in the base16 format.
resultA vector in which the decoded data is to be stored.

Definition at line 474 of file base_n.cc.

Referenced by isc::util::str::decodeFormattedHexString(), isc::dhcp_ddns::D2Dhcid::fromStr(), isc::dns::rdata::generic::Generic::Generic(), isc::dhcp::AuthKey::setAuthKey(), isc::dhcp::CfgDUID::setIdentifier(), isc::dhcp::TokenHexString::TokenHexString(), user_chk::UserId::UserId(), and isc::dhcp::OptionDataTypeUtil::writeBinary().

◆ encodeBase32Hex()

string isc::util::encode::encodeBase32Hex ( const std::vector< uint8_t > &  binary)

Encode binary data in the base32hex format.

The underlying implementation is shared with encodeBase64, and all description except the format (base32hex) equally applies.

Note: the encoding format is base32hex, not base32.

Parameters
binaryA vector object storing the data to be encoded.
Returns
A newly created string that stores base32hex encoded value for binary.

Definition at line 459 of file base_n.cc.

◆ encodeBase64()

string isc::util::encode::encodeBase64 ( const std::vector< uint8_t > &  binary)

Encode binary data in the base64 format.

This function returns a new std::string object that stores a text encoded in the base64 format for the given binary data. The resulting string will be a valid, canonical form of base64 representation as specified in RFC4648.

If memory allocation for the returned string fails, a corresponding standard exception will be thrown. This function never throws exceptions otherwise.

Parameters
binaryA vector object storing the data to be encoded.
Returns
A newly created string that stores base64 encoded value for binary.

Definition at line 449 of file base_n.cc.

Referenced by isc::http::BasicHttpAuth::BasicHttpAuth(), and isc::dns::TSIGKey::toText().

◆ encodeHex()

std::string isc::util::encode::encodeHex ( const std::vector< uint8_t > &  binary)

Encode binary data in the base16 ('hex') format.

The underlying implementation is shared with encodeBase64, and most of the description except the format (base16) equally applies. Another notable exception is that the base16 encoding doesn't require padding, so padding related considerations and the notion of canonical encoding don't apply.

Parameters
binaryA vector object storing the data to be encoded.
Returns
A newly created string that stores base16 encoded value for binary.

Definition at line 469 of file base_n.cc.

Referenced by isc::dhcp::OptionCustom::addArrayDataField(), isc::dhcp::TokenVendor::evaluate(), isc::dhcp::TokenVendorClass::evaluate(), isc::dhcp::Host::getIdentifierAsText(), isc::d2::D2CfgMgr::reverseV6Address(), isc::dhcp::CfgDUID::toElement(), isc::dhcp::Host::toElement4(), isc::dhcp::Host::toElement6(), isc::dhcp::CfgOption::toElementWithMetadata(), toHex(), isc::dhcp::Option::toHexString(), isc::dhcp_ddns::D2Dhcid::toStr(), isc::dhcp::Option6Auth::toText(), isc::dhcp::Option6PDExclude::toText(), isc::dhcp::AuthKey::toText(), and isc::dhcp::AllocEngine::updateLease6ExtendedInfo().

◆ encodeUtf8()

std::vector< uint8_t > isc::util::encode::encodeUtf8 ( const std::string &  value)

Encode value string into UTF-8.

Parameters
valueA string in latin1 i.e. no encoding.
Returns
A vector object storing the data encoded in UTF-8.

Definition at line 15 of file utf8.cc.

Referenced by isc::http::BasicHttpAuth::BasicHttpAuth().

◆ toHex()