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

Side by Side Diff: base/md5.h

Issue 266021: MD5 header cleanup for lint and items brought up when reviewing code based on... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 <string> 8 #include <string>
9 9
10 // These functions perform MD5 operations. The simplest call is MD5Sum to 10 // MD5 stands for Message Digest algorithm 5.
11 // MD5 is a robust hash function, designed for cyptography, but often used
12 // for file checksums. The code is complex and slow, but has few
13 // collisions.
14 // See Also:
15 // http://en.wikipedia.org/wiki/MD5
16
17 // These functions perform MD5 operations. The simplest call is MD5Sum() to
11 // generate the MD5 sum of the given data. 18 // generate the MD5 sum of the given data.
12 // 19 //
13 // You can also compute the MD5 sum of data incrementally by making multiple 20 // You can also compute the MD5 sum of data incrementally by making multiple
14 // calls to MD5Update: 21 // calls to MD5Update():
15 // MD5Context ctx; // intermediate MD5 data: do not use 22 // MD5Context ctx; // intermediate MD5 data: do not use
16 // MD5Init(&ctx); 23 // MD5Init(&ctx);
17 // MD5Update(&ctx, data1, length1); 24 // MD5Update(&ctx, data1, length1);
18 // MD5Update(&ctx, data2, length2); 25 // MD5Update(&ctx, data2, length2);
19 // ... 26 // ...
20 // 27 //
21 // MD5Digest digest; // the result of the computation 28 // MD5Digest digest; // the result of the computation
22 // MD5Final(&digest, &ctx); 29 // MD5Final(&digest, &ctx);
23 // 30 //
24 // You can call MD5DigestToBase16 to generate a string of the digest. 31 // You can call MD5DigestToBase16() to generate a string of the digest.
25 32
26 // The output of an MD5 operation 33 // The output of an MD5 operation
27 typedef struct MD5Digest_struct { 34 typedef struct MD5Digest_struct {
28 unsigned char a[16]; 35 unsigned char a[16];
29 } MD5Digest; 36 } MD5Digest;
30 37
31 // Used for storing intermediate data during an MD5 computation. Callers 38 // Used for storing intermediate data during an MD5 computation. Callers
32 // should not access the data. 39 // should not access the data.
33 typedef char MD5Context[88]; 40 typedef char MD5Context[88];
34 41
35 // Computes the MD5 sum of the given data buffer with the given length. 42 // Computes the MD5 sum of the given data buffer with the given length.
36 // The given 'digest' structure will be filled with the result data. 43 // The given 'digest' structure will be filled with the result data.
37 void MD5Sum(const void* data, size_t length, MD5Digest* digest); 44 void MD5Sum(const void* data, size_t length, MD5Digest* digest);
38 45
39 // Initializes the given MD5 context structure for subsequent calls to 46 // Initializes the given MD5 context structure for subsequent calls to
40 // MD5Update. 47 // MD5Update().
41 void MD5Init(MD5Context* context); 48 void MD5Init(MD5Context* context);
42 49
43 // For the given buffer of data, updates the given MD5 context with the sum of 50 // For the given buffer of data, updates the given MD5 context with the sum of
44 // the data. You can call this any number of times during the computation, 51 // the data. You can call this any number of times during the computation,
45 // exept that MD5Init must have been called first. 52 // except that MD5Init() must have been called first.
46 void MD5Update(MD5Context* context, const void* buf, size_t len); 53 void MD5Update(MD5Context* context, const void* buf, size_t len);
47 54
48 // Finalizes the MD5 operation and fills the buffer with the digest. 55 // Finalizes the MD5 operation and fills the buffer with the digest.
49 void MD5Final(MD5Digest* digest, MD5Context* pCtx); 56 void MD5Final(MD5Digest* digest, MD5Context* pCtx);
50 57
51 // Converts a digest into human-readable hexadecimal. 58 // Converts a digest into human-readable hexadecimal.
52 std::string MD5DigestToBase16(const MD5Digest& digest); 59 std::string MD5DigestToBase16(const MD5Digest& digest);
53 60
54 // Returns the MD5 (in hexadecimal) of a string. 61 // Returns the MD5 (in hexadecimal) of a string.
55 std::string MD5String(const std::string& str); 62 std::string MD5String(const std::string& str);
56 63
57 #endif // BASE_MD5_H__ 64 #endif // BASE_MD5_H_
65
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698