Chromium Code Reviews| Index: chrome/common/random.cc |
| diff --git a/chrome/common/random.cc b/chrome/common/random.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..12aa6c8a8c342f7b7f6487ad7acf8f8aeae53a79 |
| --- /dev/null |
| +++ b/chrome/common/random.cc |
| @@ -0,0 +1,19 @@ |
| +// Copyright (c) 2011 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 "chrome/common/random.h" |
| + |
| +#include <string> |
| + |
| +#include "base/base64.h" |
| +#include "base/rand_util.h" |
| + |
| +std::string Generate128BitRandomBase64String() { |
| + const int kNumberBytes = 128 / 8; |
| + std::string random_bytes(kNumberBytes, ' '); |
|
agl
2011/05/03 14:53:40
You have RandBytesAsString now, did you not want t
|
| + base::RandBytes(&random_bytes[0], kNumberBytes); |
| + std::string base64_encoded_bytes; |
| + base::Base64Encode(random_bytes, &base64_encoded_bytes); |
| + return base64_encoded_bytes; |
| +} |