Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: base/md5.h

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/macros.h ('k') | base/md5.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BASE_MD5_H_
6 #define BASE_MD5_H_
7
8 #include <stdint.h>
9
10 #include "base/base_export.h"
11 #include "base/strings/string_piece.h"
12
13 namespace base {
14
15 // MD5 stands for Message Digest algorithm 5.
16 // MD5 is a robust hash function, designed for cyptography, but often used
17 // for file checksums. The code is complex and slow, but has few
18 // collisions.
19 // See Also:
20 // http://en.wikipedia.org/wiki/MD5
21
22 // These functions perform MD5 operations. The simplest call is MD5Sum() to
23 // generate the MD5 sum of the given data.
24 //
25 // You can also compute the MD5 sum of data incrementally by making multiple
26 // calls to MD5Update():
27 // MD5Context ctx; // intermediate MD5 data: do not use
28 // MD5Init(&ctx);
29 // MD5Update(&ctx, data1, length1);
30 // MD5Update(&ctx, data2, length2);
31 // ...
32 //
33 // MD5Digest digest; // the result of the computation
34 // MD5Final(&digest, &ctx);
35 //
36 // You can call MD5DigestToBase16() to generate a string of the digest.
37
38 // The output of an MD5 operation.
39 struct MD5Digest {
40 uint8_t a[16];
41 };
42
43 // Used for storing intermediate data during an MD5 computation. Callers
44 // should not access the data.
45 typedef char MD5Context[88];
46
47 // Initializes the given MD5 context structure for subsequent calls to
48 // MD5Update().
49 BASE_EXPORT void MD5Init(MD5Context* context);
50
51 // For the given buffer of |data| as a StringPiece, updates the given MD5
52 // context with the sum of the data. You can call this any number of times
53 // during the computation, except that MD5Init() must have been called first.
54 BASE_EXPORT void MD5Update(MD5Context* context, const StringPiece& data);
55
56 // Finalizes the MD5 operation and fills the buffer with the digest.
57 BASE_EXPORT void MD5Final(MD5Digest* digest, MD5Context* context);
58
59 // MD5IntermediateFinal() generates a digest without finalizing the MD5
60 // operation. Can be used to generate digests for the input seen thus far,
61 // without affecting the digest generated for the entire input.
62 BASE_EXPORT void MD5IntermediateFinal(MD5Digest* digest,
63 const MD5Context* context);
64
65 // Converts a digest into human-readable hexadecimal.
66 BASE_EXPORT std::string MD5DigestToBase16(const MD5Digest& digest);
67
68 // 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.
70 BASE_EXPORT void MD5Sum(const void* data, size_t length, MD5Digest* digest);
71
72 // Returns the MD5 (in hexadecimal) of a string.
73 BASE_EXPORT std::string MD5String(const StringPiece& str);
74
75 } // namespace base
76
77 #endif // BASE_MD5_H_
OLDNEW
« no previous file with comments | « base/macros.h ('k') | base/md5.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698