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

Unified Diff: chrome/browser/sync/util/crypto_helpers.cc

Issue 6873156: Move crypto_helpers from sync to base (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Follow bbretw review Created 9 years, 8 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
« no previous file with comments | « chrome/browser/sync/util/crypto_helpers.h ('k') | chrome/browser/sync/util/crypto_helpers_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/util/crypto_helpers.cc
diff --git a/chrome/browser/sync/util/crypto_helpers.cc b/chrome/browser/sync/util/crypto_helpers.cc
deleted file mode 100644
index 36c5586eb24e0934eed37feaf3bc568f1ff56a12..0000000000000000000000000000000000000000
--- a/chrome/browser/sync/util/crypto_helpers.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (c) 2010 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/browser/sync/util/crypto_helpers.h"
-
-#include <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/format_macros.h"
-#include "base/logging.h"
-#include "base/base64.h"
-#include "base/rand_util.h"
-#include "base/string_number_conversions.h"
-#include "base/string_util.h"
-
-using std::string;
-using std::vector;
-
-MD5Calculator::MD5Calculator() {
- MD5Init(&context_);
-}
-
-MD5Calculator::~MD5Calculator() {}
-
-void MD5Calculator::AddData(const unsigned char* data, int length) {
- CHECK(bin_digest_.empty());
- MD5Update(&context_, data, length);
-}
-
-void MD5Calculator::CalcDigest() {
- if (bin_digest_.empty()) {
- MD5Digest digest;
- MD5Final(&digest, &context_);
- bin_digest_.assign(digest.a, digest.a + arraysize(digest.a));
- }
-}
-
-const vector<uint8>& MD5Calculator::GetDigest() {
- CalcDigest();
- return bin_digest_;
-}
-
-std::string MD5Calculator::GetHexDigest() {
- CalcDigest();
- string hex = base::HexEncode(reinterpret_cast<char*>(&bin_digest_.front()),
- bin_digest_.size());
- StringToLowerASCII(&hex);
- return hex;
-}
-
-void GetRandomBytes(char* output, int output_length) {
- uint64 random_int;
- const char* random_int_bytes = reinterpret_cast<const char*>(&random_int);
- int random_int_size = sizeof(random_int);
- for (int i = 0; i < output_length; i += random_int_size) {
- random_int = base::RandUint64();
- int copy_count = std::min(output_length - i, random_int_size);
- memcpy(output + i, random_int_bytes, copy_count);
- }
-}
-
-string Generate128BitRandomHexString() {
- const int kNumberBytes = 128 / 8;
- std::string random_bytes(kNumberBytes, ' ');
- GetRandomBytes(&random_bytes[0], kNumberBytes);
- std::string base64_encoded_bytes;
- base::Base64Encode(random_bytes, &base64_encoded_bytes);
- return base64_encoded_bytes;
-}
« no previous file with comments | « chrome/browser/sync/util/crypto_helpers.h ('k') | chrome/browser/sync/util/crypto_helpers_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698