OLD | NEW |
1 // Copyright (c) 2011 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 BASE_MD5_H_ | 5 #ifndef BASE_MD5_H_ |
6 #define BASE_MD5_H_ | 6 #define BASE_MD5_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // MD5Update(&ctx, data1, length1); | 29 // MD5Update(&ctx, data1, length1); |
30 // MD5Update(&ctx, data2, length2); | 30 // MD5Update(&ctx, data2, length2); |
31 // ... | 31 // ... |
32 // | 32 // |
33 // MD5Digest digest; // the result of the computation | 33 // MD5Digest digest; // the result of the computation |
34 // MD5Final(&digest, &ctx); | 34 // MD5Final(&digest, &ctx); |
35 // | 35 // |
36 // You can call MD5DigestToBase16() to generate a string of the digest. | 36 // You can call MD5DigestToBase16() to generate a string of the digest. |
37 | 37 |
38 // The output of an MD5 operation. | 38 // The output of an MD5 operation. |
39 struct MD5Digest { | 39 typedef uint8_t MD5Digest[16]; |
40 uint8_t a[16]; | |
41 }; | |
42 | 40 |
43 // Used for storing intermediate data during an MD5 computation. Callers | 41 // Used for storing intermediate data during an MD5 computation. Callers |
44 // should not access the data. | 42 // should not access the data. |
45 typedef char MD5Context[88]; | 43 typedef char MD5Context[88]; |
46 | 44 |
47 // Initializes the given MD5 context structure for subsequent calls to | 45 // Initializes the given MD5 context structure for subsequent calls to |
48 // MD5Update(). | 46 // MD5Update(). |
49 BASE_EXPORT void MD5Init(MD5Context* context); | 47 BASE_EXPORT void MD5Init(MD5Context* context); |
50 | 48 |
51 // For the given buffer of |data| as a StringPiece, updates the given MD5 | 49 // For the given buffer of |data| as a StringPiece, updates the given MD5 |
(...skipping 16 matching lines...) Expand all Loading... |
68 // Computes the MD5 sum of the given data buffer with the given length. | 66 // Computes the MD5 sum of the given data buffer with the given length. |
69 // The given 'digest' structure will be filled with the result data. | 67 // The given 'digest' structure will be filled with the result data. |
70 BASE_EXPORT void MD5Sum(const void* data, size_t length, MD5Digest* digest); | 68 BASE_EXPORT void MD5Sum(const void* data, size_t length, MD5Digest* digest); |
71 | 69 |
72 // Returns the MD5 (in hexadecimal) of a string. | 70 // Returns the MD5 (in hexadecimal) of a string. |
73 BASE_EXPORT std::string MD5String(const StringPiece& str); | 71 BASE_EXPORT std::string MD5String(const StringPiece& str); |
74 | 72 |
75 } // namespace base | 73 } // namespace base |
76 | 74 |
77 #endif // BASE_MD5_H_ | 75 #endif // BASE_MD5_H_ |
OLD | NEW |