summaryrefslogtreecommitdiffstats
path: root/chrome/common/random.cc
blob: 303d296ca6c5dc7e3672035115834c0932af21a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 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 base64_encoded_bytes;
  base::Base64Encode(base::RandBytesAsString(kNumberBytes),
                     &base64_encoded_bytes);
  return base64_encoded_bytes;
}