From a82bd628c1635d97ceea48308665295314d51bb2 Mon Sep 17 00:00:00 2001 From: cpubug Date: Mon, 7 Apr 2014 22:01:24 +0400 Subject: [PATCH] compute IdentHash in Identity method --- Identity.cpp | 7 +++++++ Identity.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/Identity.cpp b/Identity.cpp index 652dc1e1..435c0c9b 100644 --- a/Identity.cpp +++ b/Identity.cpp @@ -24,6 +24,13 @@ namespace data { size_t count = Base64ToByteStream (s.c_str(), s.length(), reinterpret_cast (this), sizeof (Identity)); return count == sizeof(Identity); + } + + IdentHash Identity::Hash() + { + IdentHash hash; + CryptoPP::SHA256().CalculateDigest(reinterpret_cast(&hash), reinterpret_cast (this), sizeof (Identity)); + return hash; } PrivateKeys& PrivateKeys::operator=(const Keys& keys) diff --git a/Identity.h b/Identity.h index 19e5a007..902153dc 100644 --- a/Identity.h +++ b/Identity.h @@ -9,6 +9,8 @@ namespace i2p { namespace data { + class IdentHash; + #pragma pack(1) struct DHKeysPair // transient keys for transport sessions @@ -33,6 +35,7 @@ namespace data Identity& operator=(const Keys& keys); bool FromBase64(const std::string&); + IdentHash Hash(); }; struct PrivateKeys // for eepsites