aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 1e63d70..4986e6c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -34,19 +34,24 @@ string createChannelJoinKey(const unique_ptr<odhtdb::DatabaseCreateResponse> &da
string createJoinKeyFromDatabaseNode(const odhtdb::DatabaseNode &databaseNode)
{
- return databaseNode.getRequestHash()->toString() + "&" + odhtdb::bin2hex((const char*)databaseNode.getNodeEncryptionKey()->data, databaseNode.getNodeEncryptionKey()->size);
+ string result;
+ result += databaseNode.getRequestHash()->toString();
+ result += "&";
+ result += odhtdb::bin2hex((const char*)databaseNode.getNodeEncryptionKey()->data, databaseNode.getNodeEncryptionKey()->size);
+ return result;
}
odhtdb::DatabaseNode createDatabaseNodeFromJoinKey(const string &joinKey)
{
- string nodeHashStr = odhtdb::hex2bin(joinKey.c_str(), 64);
+ string nodeHashRaw = odhtdb::hex2bin(joinKey.c_str(), 64);
shared_ptr<odhtdb::Hash> nodeHash = make_shared<odhtdb::Hash>();
- memcpy(nodeHash->getData(), nodeHashStr.data(), nodeHashStr.size());
+ memcpy(nodeHash->getData(), nodeHashRaw.data(), nodeHashRaw.size());
- string nodeEncryptionKeyStr = odhtdb::hex2bin(joinKey.c_str() + 65, 64);
+ string nodeEncryptionKeyRaw = odhtdb::hex2bin(joinKey.c_str() + 65, 64);
shared_ptr<odhtdb::OwnedMemory> encryptionKey = make_shared<odhtdb::OwnedMemory>();
- encryptionKey->data = new char[nodeEncryptionKeyStr.size()];
- encryptionKey->size = nodeEncryptionKeyStr.size();
+ encryptionKey->data = new char[nodeEncryptionKeyRaw.size()];
+ memcpy(encryptionKey->data, nodeEncryptionKeyRaw.data(), nodeEncryptionKeyRaw.size());
+ encryptionKey->size = nodeEncryptionKeyRaw.size();
return odhtdb::DatabaseNode(encryptionKey, nodeHash);
}