diff --git a/Identity.cpp b/Identity.cpp index 387eef50..652dc1e1 100644 --- a/Identity.cpp +++ b/Identity.cpp @@ -6,6 +6,7 @@ #include #include "CryptoConst.h" #include "Identity.h" +#include "base64.h" namespace i2p { @@ -17,6 +18,12 @@ namespace data memcpy (publicKey, keys.publicKey, sizeof (publicKey) + sizeof (signingKey)); memset (certificate, 0, sizeof (certificate)); return *this; + } + + bool Identity::FromBase64 (const std::string& s) + { + size_t count = Base64ToByteStream (s.c_str(), s.length(), reinterpret_cast (this), sizeof (Identity)); + return count == sizeof(Identity); } PrivateKeys& PrivateKeys::operator=(const Keys& keys) diff --git a/Identity.h b/Identity.h index 1dafdef4..19e5a007 100644 --- a/Identity.h +++ b/Identity.h @@ -32,6 +32,7 @@ namespace data uint8_t certificate[3]; Identity& operator=(const Keys& keys); + bool FromBase64(const std::string&); }; struct PrivateKeys // for eepsites