// DragonX Wallet - ImGui Edition
// Copyright 2024-2026 The Hush Developers
// Released under the GPLv3

#pragma once

#include <string>
#include <vector>
#include <cstdint>

namespace dragonx {
namespace util {

/**
 * @brief Base64 encoding/decoding utilities
 */

/**
 * @brief Encode binary data to base64 string
 * @param data Input data
 * @param len Length of input data
 * @return Base64 encoded string
 */
std::string base64_encode(const unsigned char* data, size_t len);

/**
 * @brief Encode string to base64
 * @param input Input string
 * @return Base64 encoded string
 */
inline std::string base64_encode(const std::string& input) {
    return base64_encode(reinterpret_cast<const unsigned char*>(input.data()), input.size());
}

/**
 * @brief Decode base64 string to binary data
 * @param encoded Base64 encoded string
 * @return Decoded binary data
 */
std::vector<unsigned char> base64_decode(const std::string& encoded);

/**
 * @brief Decode base64 string to string
 * @param encoded Base64 encoded string
 * @return Decoded string
 */
inline std::string base64_decode_string(const std::string& encoded) {
    auto decoded = base64_decode(encoded);
    return std::string(decoded.begin(), decoded.end());
}

} // namespace util
} // namespace dragonx
