diff --git a/include/lokinet/lokinet_misc.h b/include/lokinet/lokinet_misc.h index dea41f9ba..fa20911e4 100644 --- a/include/lokinet/lokinet_misc.h +++ b/include/lokinet/lokinet_misc.h @@ -21,6 +21,11 @@ extern "C" int EXPORT lokinet_log_level(const char*); + /// @brief take in hex and turn it into base32z + /// @return value must be free()'d later + char* EXPORT + lokinet_hex_to_base32z(const char* hex); + #ifdef __cplusplus } #endif diff --git a/llarp/lokinet_shared.cpp b/llarp/lokinet_shared.cpp index 0766be0f4..3020889e2 100644 --- a/llarp/lokinet_shared.cpp +++ b/llarp/lokinet_shared.cpp @@ -12,6 +12,8 @@ #include +#include + #include #ifdef _WIN32 @@ -546,6 +548,13 @@ extern "C" return id; } + char* EXPORT + lokinet_hex_to_base32z(const char* hex) + { + const auto base32z = oxenmq::to_base32z(oxenmq::from_hex(std::string{hex})); + return strdup(base32z.c_str()); + } + void EXPORT lokinet_close_stream(int stream_id, struct lokinet_context* ctx) {