From f5f56e1a1c4d9e9496fcb9d81131066a964ccd23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 14:15:43 +0200 Subject: Adding upstream version 2.4.1. Signed-off-by: Daniel Baumann --- src/lib/util/encode/base32hex.h | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/lib/util/encode/base32hex.h (limited to 'src/lib/util/encode/base32hex.h') diff --git a/src/lib/util/encode/base32hex.h b/src/lib/util/encode/base32hex.h new file mode 100644 index 0000000..0a85b36 --- /dev/null +++ b/src/lib/util/encode/base32hex.h @@ -0,0 +1,56 @@ +// Copyright (C) 2009-2015 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef BASE32HEX_H +#define BASE32HEX_H 1 + +#include +#include +#include + +// +// Note: this helper module isn't specific to the DNS protocol per se. +// We should probably move this to somewhere else, possibly in some common +// utility area. +// + +namespace isc { +namespace util { +namespace encode { + +/// \brief Encode binary data in the base32hex format. +/// +/// The underlying implementation is shared with \c encodeBase64, and all +/// description except the format (base32hex) equally applies. +/// +/// Note: the encoding format is base32hex, not base32. +/// +/// \param binary A vector object storing the data to be encoded. +/// \return A newly created string that stores base32hex encoded value for +/// binary. +std::string encodeBase32Hex(const std::vector& binary); + +/// \brief Decode a text encoded in the base32hex format into the +/// original %data. +/// +/// The underlying implementation is shared with \c decodeBase64, and all +/// description except the format (base32hex) equally applies. +/// +/// Note: the encoding format is base32hex, not base32. +/// +/// \param input A text encoded in the base32hex format. +/// \param result A vector in which the decoded %data is to be stored. +void decodeBase32Hex(const std::string& input, std::vector& result); + +} // namespace encode +} // namespace util +} // namespace isc + +#endif // BASE32HEX_H + +// Local Variables: +// mode: c++ +// End: -- cgit v1.2.3