Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1059)

Unified Diff: base/sha1_portable.cc

Issue 6661025: Add base::SHA1HashBytes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Actually, base/sha1_win.cc is not used, so don't touch it Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« base/sha1.h ('K') | « base/sha1.h ('k') | base/sha1_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sha1_portable.cc
diff --git a/base/sha1_portable.cc b/base/sha1_portable.cc
index cc05a5c91f0601ac0fbe651df7f76a3398fef862..bac86f947ba57873617d98265e8947d516dc56ef 100644
--- a/base/sha1_portable.cc
+++ b/base/sha1_portable.cc
@@ -5,6 +5,7 @@
#include "base/sha1.h"
#include "base/basictypes.h"
+#include <cstring>
wtc 2011/03/11 18:46:15 1. Nit: I recommend including the C header <string
hans 2011/03/13 19:48:16 done
namespace base {
@@ -203,4 +204,13 @@ std::string SHA1HashString(const std::string& str) {
return out;
}
+void SHA1HashBytes(const unsigned char* data, size_t len,
+ unsigned char* hash_array) {
+ SecureHashAlgorithm sha;
+ sha.Update(data, len);
+ sha.Final();
+
+ std::memcpy(hash_array, sha.Digest(), SecureHashAlgorithm::kDigestSizeBytes);
+}
+
} // namespace base
« base/sha1.h ('K') | « base/sha1.h ('k') | base/sha1_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698