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

Unified Diff: base/nonce.cc

Issue 2333443002: Add base::UnguessableToken (Closed)
Patch Set: Created 4 years, 3 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: base/nonce.cc
diff --git a/base/nonce.cc b/base/nonce.cc
new file mode 100644
index 0000000000000000000000000000000000000000..54f6b8dfbdebd8edded003d407f3ddf2c9f0f31c
--- /dev/null
+++ b/base/nonce.cc
@@ -0,0 +1,17 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/nonce.h"
+
+#include "base/rand_util.h"
+
+namespace base {
+Nonce Nonce::Generate() {
+ Nonce nonce;
+ // Use base::RandBytes instead of crypto::RandBytes, because crypto calls the
+ // base version directly, and to prevent the dependency from base/ to crypto/.
+ base::RandBytes(&nonce, sizeof(nonce));
+ return nonce;
+}
+} // namespace base

Powered by Google App Engine
This is Rietveld 408576698