| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 // An object to handle calculation of MD5 sums. | |
| 13 #include "base/basictypes.h" | |
| 14 #include "base/md5.h" | |
| 15 #include "base/port.h" | |
| 16 | |
| 17 class MD5Calculator { | |
| 18 protected: | |
| 19 MD5Context context_; | |
| 20 std::vector<uint8> bin_digest_; | |
| 21 | |
| 22 void CalcDigest(); | |
| 23 public: | |
| 24 MD5Calculator(); | |
| 25 ~MD5Calculator(); | |
| 26 void AddData(const uint8* data, int length); | |
| 27 void AddData(const char* data, int length) { | |
| 28 AddData(reinterpret_cast<const uint8*>(data), length); | |
| 29 } | |
| 30 std::string GetHexDigest(); | |
| 31 const std::vector<uint8>& GetDigest(); | |
| 32 private: | |
| 33 DISALLOW_COPY_AND_ASSIGN(MD5Calculator); | |
| 34 }; | |
| 35 | |
| 36 void GetRandomBytes(char* output, int output_length); | |
| 37 std::string Generate128BitRandomHexString(); | |
| 38 | |
| 39 #endif // CHROME_BROWSER_SYNC_UTIL_CRYPTO_HELPERS_H_ | |
| OLD | NEW |