OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_UTIL_CRYPTO_HELPERS_H_ |
| 6 #define CHROME_BROWSER_SYNC_UTIL_CRYPTO_HELPERS_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 // An object to handle calculation of MD5 sums. |
| 12 #include "base/basictypes.h" |
| 13 #include "base/logging.h" |
| 14 #include "base/md5.h" |
| 15 #include "base/port.h" |
| 16 #include "chrome/browser/sync/util/sync_types.h" |
| 17 |
| 18 class MD5Calculator { |
| 19 protected: |
| 20 MD5Context context_; |
| 21 std::vector<uint8> bin_digest_; |
| 22 |
| 23 void CalcDigest(); |
| 24 public: |
| 25 MD5Calculator(); |
| 26 ~MD5Calculator() {} |
| 27 void AddData(const uint8* data, int length); |
| 28 void AddData(const char* data, int length) { |
| 29 AddData(reinterpret_cast<const uint8*>(data), length); |
| 30 } |
| 31 PathString GetHexDigest(); |
| 32 std::vector<uint8> GetDigest(); |
| 33 private: |
| 34 DISALLOW_COPY_AND_ASSIGN(MD5Calculator); |
| 35 }; |
| 36 |
| 37 void GetRandomBytes(char* output, int output_length); |
| 38 std::string Generate128BitRandomHexString(); |
| 39 |
| 40 #endif // CHROME_BROWSER_SYNC_UTIL_CRYPTO_HELPERS_H_ |
OLD | NEW |