aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksi Lindeman <0xdec05eba@gmail.com>2018-03-13 08:20:57 +0100
committerAleksi Lindeman <0xdec05eba@gmail.com>2018-03-13 08:21:08 +0100
commit05bcf662835aefe4b63439860825345afbc911f4 (patch)
tree445d5213a4764797ff6665fb38f48ac284d225f2 /src
parent1354b690c4dafa080d5b59b6ffe67959747c4b5e (diff)
Fix PrivateKey/PublicKey ::toString
Diffstat (limited to 'src')
-rw-r--r--src/Signature.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/Signature.cpp b/src/Signature.cpp
index cba5954..b6fb12a 100644
--- a/src/Signature.cpp
+++ b/src/Signature.cpp
@@ -1,7 +1,7 @@
#include "../include/odhtdb/Signature.hpp"
#include "../include/odhtdb/Hash.hpp"
+#include "../include/odhtdb/bin2hex.hpp"
#include <sodium/crypto_sign_ed25519.h>
-#include <sodium/utils.h>
#include <cstring>
using namespace std;
@@ -61,10 +61,7 @@ namespace odhtdb
string PublicKey::toString() const
{
- string result;
- result.resize(PUBLIC_KEY_NUM_BYTES * 2 + 1);
- sodium_bin2hex(&result[0], PUBLIC_KEY_NUM_BYTES * 2 + 1, (const unsigned char*)data, PUBLIC_KEY_NUM_BYTES);
- return result;
+ return bin2hex(data, PUBLIC_KEY_NUM_BYTES);
}
PrivateKey::PrivateKey(const char *_data, size_t size)
@@ -108,10 +105,7 @@ namespace odhtdb
string PrivateKey::toString() const
{
- string result;
- result.resize(PRIVATE_KEY_NUM_BYTES * 2);
- sodium_bin2hex(&result[0], PRIVATE_KEY_NUM_BYTES * 2 + 1, (const unsigned char*)data, PRIVATE_KEY_NUM_BYTES);
- return result;
+ return bin2hex(data, PRIVATE_KEY_NUM_BYTES);
}
KeyPair::KeyPair()