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

Unified Diff: components/proximity_auth/cryptauth/cryptauth_enrollment_utils.cc

Issue 1308393007: Add CryptAuth managers to EasyUnlockServiceRegular (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix windows compile Created 5 years, 4 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
Index: components/proximity_auth/cryptauth/cryptauth_enrollment_utils.cc
diff --git a/components/proximity_auth/cryptauth/cryptauth_enrollment_utils.cc b/components/proximity_auth/cryptauth/cryptauth_enrollment_utils.cc
index 476721c97c5caef0306f5bc113514e99fa7b52ac..ee5cec2eae8baf0f75f4278465a7fa679b4970ff 100644
--- a/components/proximity_auth/cryptauth/cryptauth_enrollment_utils.cc
+++ b/components/proximity_auth/cryptauth/cryptauth_enrollment_utils.cc
@@ -4,11 +4,33 @@
#include "components/proximity_auth/cryptauth/cryptauth_enrollment_utils.h"
+#include <math.h>
+
+#include "base/md5.h"
#include "base/sha1.h"
#include "components/proximity_auth/cryptauth/base64url.h"
namespace proximity_auth {
+int64_t HashStringToInt64(const std::string& string) {
+ base::MD5Context context;
+ base::MD5Init(&context);
+ base::MD5Update(&context, string);
+
+ base::MD5Digest digest;
+ base::MD5Final(&digest, &context);
+
+ // Fold the digest into an int64 value. |digest.a| is a 16-byte array, so we
+ // sum the two 8-byte halves of the digest to create the hash.
+ int64_t hash = 0;
+ for (size_t i = 0; i < sizeof(digest.a); ++i) {
+ uint8_t byte = digest.a[i];
+ hash += static_cast<int64_t>(byte) << (i % sizeof(int64_t));
+ }
+
+ return hash;
+}
+
std::string CalculateDeviceUserId(const std::string& device_id,
const std::string& user_id) {
std::string device_user_id;

Powered by Google App Engine
This is Rietveld 408576698