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

Unified Diff: components/cryptauth/remote_device.cc

Issue 2570383002: CryptAuth: Add GetId() and a GetTruncatedIdForLogs() functions to RemoteDevice. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « components/cryptauth/remote_device.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cryptauth/remote_device.cc
diff --git a/components/cryptauth/remote_device.cc b/components/cryptauth/remote_device.cc
index f30aee139320b4b32e0a63b6d633cdfec7b41606..da0a0583df0dfe0269594a9a15c079c7d7e19246 100644
--- a/components/cryptauth/remote_device.cc
+++ b/components/cryptauth/remote_device.cc
@@ -4,6 +4,8 @@
#include "components/cryptauth/remote_device.h"
+#include "base/base64.h"
+
namespace cryptauth {
RemoteDevice::RemoteDevice() : bluetooth_type(BLUETOOTH_CLASSIC) {}
@@ -27,4 +29,19 @@ RemoteDevice::RemoteDevice(const RemoteDevice& other) = default;
RemoteDevice::~RemoteDevice() {}
+std::string RemoteDevice::GetDeviceId() {
+ std::string to_return;
+ base::Base64Encode(public_key, &to_return);
+ return to_return;
+}
+
+std::string RemoteDevice::GetTruncatedDeviceIdForLogs() {
+ std::string id = GetDeviceId();
+ if (id.length() <= 10) {
+ return id;
+ }
+
+ return id.substr(0, 5) + "..." + id.substr(id.length() - 5, id.length());
+}
+
} // namespace cryptauth
« no previous file with comments | « components/cryptauth/remote_device.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698