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

Side by Side Diff: base/md5.cc

Issue 7466003: MD5Update function uses StringPiece instead of raw buffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved to StringPiece Created 9 years, 5 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 | « base/md5.h ('k') | base/md5_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // The original file was copied from sqlite, and was in the public domain. 1 // The original file was copied from sqlite, and was in the public domain.
2 // Modifications Copyright 2006 Google Inc. All Rights Reserved 2 // Modifications Copyright 2006 Google Inc. All Rights Reserved
3 3
4 /* 4 /*
5 * This code implements the MD5 message-digest algorithm. 5 * This code implements the MD5 message-digest algorithm.
6 * The algorithm is due to Ron Rivest. This code was 6 * The algorithm is due to Ron Rivest. This code was
7 * written by Colin Plumb in 1993, no copyright is claimed. 7 * written by Colin Plumb in 1993, no copyright is claimed.
8 * This code is in the public domain; do with it what you wish. 8 * This code is in the public domain; do with it what you wish.
9 * 9 *
10 * Equivalent code is available from RSA Data Security, Inc. 10 * Equivalent code is available from RSA Data Security, Inc.
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 MD5Transform(ctx->buf, (uint32 *)ctx->in); 203 MD5Transform(ctx->buf, (uint32 *)ctx->in);
204 buf += 64; 204 buf += 64;
205 len -= 64; 205 len -= 64;
206 } 206 }
207 207
208 /* Handle any remaining bytes of data. */ 208 /* Handle any remaining bytes of data. */
209 209
210 memcpy(ctx->in, buf, len); 210 memcpy(ctx->in, buf, len);
211 } 211 }
212 212
213 // Call through to the raw pointer version.
214 void MD5Update(MD5Context* context, const StringPiece& data) {
brettw 2011/07/20 20:26:28 I think you should change the original function ra
215 MD5Update(context, data.data(), data.size());
216 }
217
213 /* 218 /*
214 * Final wrapup - pad to 64-byte boundary with the bit pattern 219 * Final wrapup - pad to 64-byte boundary with the bit pattern
215 * 1 0* (64-bit count of bits processed, MSB-first) 220 * 1 0* (64-bit count of bits processed, MSB-first)
216 */ 221 */
217 void MD5Final(MD5Digest* digest, MD5Context* context) { 222 void MD5Final(MD5Digest* digest, MD5Context* context) {
218 struct Context *ctx = (struct Context *)context; 223 struct Context *ctx = (struct Context *)context;
219 unsigned count; 224 unsigned count;
220 unsigned char *p; 225 unsigned char *p;
221 226
222 /* Compute number of bytes mod 64 */ 227 /* Compute number of bytes mod 64 */
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 MD5Final(digest, &ctx); 282 MD5Final(digest, &ctx);
278 } 283 }
279 284
280 std::string MD5String(const std::string& str) { 285 std::string MD5String(const std::string& str) {
281 MD5Digest digest; 286 MD5Digest digest;
282 MD5Sum(str.data(), str.length(), &digest); 287 MD5Sum(str.data(), str.length(), &digest);
283 return MD5DigestToBase16(digest); 288 return MD5DigestToBase16(digest);
284 } 289 }
285 290
286 } // namespace base 291 } // namespace base
OLDNEW
« no previous file with comments | « base/md5.h ('k') | base/md5_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698