add binToHex with Poco::Nullable<Poco::Data::Blob> for easy use with public keys

This commit is contained in:
Dario 2020-08-25 16:18:38 +02:00 committed by Ulf Gebhardt
parent 99846b0c61
commit fbc058cf82
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
2 changed files with 14 additions and 1 deletions

View File

@ -176,6 +176,16 @@ namespace DataTypeConverter
return hexString;
}
std::string binToHex(const Poco::Nullable<Poco::Data::BLOB>& nullableBin)
{
if (nullableBin.isNull()) {
return "0x0";
}
else {
return binToHex(nullableBin.value().content().data(), nullableBin.value().content().size());
}
}
std::string pubkeyToHex(const unsigned char* pubkey)
{
auto mm = MemoryManager::getInstance();

View File

@ -5,9 +5,10 @@
#include "../SingletonManager/MemoryManager.h"
#include "Poco/Timespan.h"
#include "Poco/Nullable.h"
#include "Poco/Data/LOB.h"
#include "../SingletonManager/LanguageManager.h"
namespace DataTypeConverter {
enum NumberParseState
@ -26,7 +27,9 @@ namespace DataTypeConverter {
std::string binToBase64(const MemoryBin* data);
std::string binToHex(const unsigned char* data, size_t size);
std::string binToHex(const Poco::Nullable<Poco::Data::BLOB>& nullableBin);
inline std::string binToHex(const MemoryBin* data) { return binToHex(data->data(), data->size());}
//! \param pubkey pointer to array with crypto_sign_PUBLICKEYBYTES size