| 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> |
| 9 |
| 8 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| 9 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
| 10 | 12 |
| 11 namespace base { | 13 namespace base { |
| 12 | 14 |
| 13 // MD5 stands for Message Digest algorithm 5. | 15 // MD5 stands for Message Digest algorithm 5. |
| 14 // MD5 is a robust hash function, designed for cyptography, but often used | 16 // MD5 is a robust hash function, designed for cyptography, but often used |
| 15 // for file checksums. The code is complex and slow, but has few | 17 // for file checksums. The code is complex and slow, but has few |
| 16 // collisions. | 18 // collisions. |
| 17 // See Also: | 19 // See Also: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 28 // MD5Update(&ctx, data2, length2); | 30 // MD5Update(&ctx, data2, length2); |
| 29 // ... | 31 // ... |
| 30 // | 32 // |
| 31 // MD5Digest digest; // the result of the computation | 33 // MD5Digest digest; // the result of the computation |
| 32 // MD5Final(&digest, &ctx); | 34 // MD5Final(&digest, &ctx); |
| 33 // | 35 // |
| 34 // You can call MD5DigestToBase16() to generate a string of the digest. | 36 // You can call MD5DigestToBase16() to generate a string of the digest. |
| 35 | 37 |
| 36 // The output of an MD5 operation. | 38 // The output of an MD5 operation. |
| 37 struct MD5Digest { | 39 struct MD5Digest { |
| 38 unsigned char a[16]; | 40 uint8_t a[16]; |
| 39 }; | 41 }; |
| 40 | 42 |
| 41 // Used for storing intermediate data during an MD5 computation. Callers | 43 // Used for storing intermediate data during an MD5 computation. Callers |
| 42 // should not access the data. | 44 // should not access the data. |
| 43 typedef char MD5Context[88]; | 45 typedef char MD5Context[88]; |
| 44 | 46 |
| 45 // Computes the MD5 sum of the given data buffer with the given length. | 47 // Computes the MD5 sum of the given data buffer with the given length. |
| 46 // The given 'digest' structure will be filled with the result data. | 48 // The given 'digest' structure will be filled with the result data. |
| 47 BASE_EXPORT void MD5Sum(const void* data, size_t length, MD5Digest* digest); | 49 BASE_EXPORT void MD5Sum(const void* data, size_t length, MD5Digest* digest); |
| 48 | 50 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 66 | 68 |
| 67 // Converts a digest into human-readable hexadecimal. | 69 // Converts a digest into human-readable hexadecimal. |
| 68 BASE_EXPORT std::string MD5DigestToBase16(const MD5Digest& digest); | 70 BASE_EXPORT std::string MD5DigestToBase16(const MD5Digest& digest); |
| 69 | 71 |
| 70 // Returns the MD5 (in hexadecimal) of a string. | 72 // Returns the MD5 (in hexadecimal) of a string. |
| 71 BASE_EXPORT std::string MD5String(const StringPiece& str); | 73 BASE_EXPORT std::string MD5String(const StringPiece& str); |
| 72 | 74 |
| 73 } // namespace base | 75 } // namespace base |
| 74 | 76 |
| 75 #endif // BASE_MD5_H_ | 77 #endif // BASE_MD5_H_ |
| OLD | NEW |