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