Index: base/sha2.h |
diff --git a/base/sha2.h b/base/sha2.h |
index 19e41c30b227a97f771e9d0ee522fc6fc55a8c73..8b9a98ce705f809e94dcd99c497a9c45c8bd36fd 100644 |
--- a/base/sha2.h |
+++ b/base/sha2.h |
@@ -8,6 +8,8 @@ |
#include <string> |
+#include "base/basictypes.h" |
+ |
namespace base { |
// These functions perform SHA-256 operations. |
@@ -27,6 +29,24 @@ void SHA256HashString(const std::string& str, void* output, size_t len); |
// string. |
std::string SHA256HashString(const std::string& str); |
+// A wrapper for calculating SHA256 when the full string is not known in |
+// advance. |
+class SHA256Context { |
wtc
2011/01/21 22:48:51
Please name this class SHA256Hash or SHA256. (I a
bulach
2011/01/24 20:54:33
I liked this idea, seems more flexible.
I extracte
|
+ public: |
+ virtual ~SHA256Context() {} |
+ |
+ static SHA256Context* Create(); |
+ |
+ virtual void Update(const std::string& str) = 0; |
+ virtual void Finish(void* output, size_t len) = 0; |
wtc
2011/01/21 22:48:51
This method should be named Final.
bulach
2011/01/24 20:54:33
done, in the new files.
|
+ |
+ protected: |
+ SHA256Context() {} |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(SHA256Context); |
+}; |
+ |
} // namespace base |
#endif // BASE_SHA2_H_ |