From ceb2ec1bc06f3ad68b0eb49bfb46f053344ec0de Mon Sep 17 00:00:00 2001 From: cpubug Date: Wed, 23 Apr 2014 22:43:54 +0400 Subject: [PATCH] load IdentHash from base32 string --- Identity.cpp | 6 ++++++ Identity.h | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Identity.cpp b/Identity.cpp index c7c3ed0e..5a59e26e 100644 --- a/Identity.cpp +++ b/Identity.cpp @@ -40,6 +40,12 @@ namespace data return *this; } + bool IdentHash::FromBase32(const std::string& s) + { + size_t count = Base32ToByteStream(s.c_str(), s.length(), m_Hash, sizeof(m_Hash)); + return count == sizeof(m_Hash); + } + Keys CreateRandomKeys () { Keys keys; diff --git a/Identity.h b/Identity.h index ff35a7db..12ca8535 100644 --- a/Identity.h +++ b/Identity.h @@ -73,7 +73,9 @@ namespace data bool operator== (const IdentHash& other) const { return !memcmp (m_Hash, other.m_Hash, 32); }; bool operator< (const IdentHash& other) const { return memcmp (m_Hash, other.m_Hash, 32) < 0; }; - + + bool FromBase32(const std::string&); + private: uint8_t m_Hash[32];