Chromium Code Reviews| Index: base/md5.cc |
| diff --git a/base/md5.cc b/base/md5.cc |
| index 2211a285e5badf8ef181c3910b10c73e347be4ce..0961fb1fcf88349cdcb2c04c6d90f37d87ddf894 100644 |
| --- a/base/md5.cc |
| +++ b/base/md5.cc |
| @@ -1,6 +1,10 @@ |
| // The original file was copied from sqlite, and was in the public domain. |
| // Modifications Copyright 2006 Google Inc. All Rights Reserved |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
|
tfarina
2011/07/21 22:21:24
Could you put this as the first three lines, then
dominich
2011/07/25 20:58:27
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| /* |
| * This code implements the MD5 message-digest algorithm. |
| * The algorithm is due to Ron Rivest. This code was |
| @@ -164,7 +168,9 @@ void MD5Init(MD5Context* context) { |
| * Update context to reflect the concatenation of another buffer full |
| * of bytes. |
| */ |
| -void MD5Update(MD5Context* context, const void* inbuf, size_t len) { |
| +void MD5Update(MD5Context* context, const StringPiece& data) { |
| + const unsigned char* inbuf = (const unsigned char*) data.data(); |
|
tfarina
2011/07/21 22:21:24
no space between (const unsigned char*) and data.d
dominich
2011/07/25 20:58:27
Done.
|
| + size_t len = data.size(); |
| struct Context *ctx = (struct Context *)context; |
| const unsigned char* buf = (const unsigned char*)inbuf; |
| uint32 t; |
| @@ -273,11 +279,12 @@ std::string MD5DigestToBase16(const MD5Digest& digest) { |
| void MD5Sum(const void* data, size_t length, MD5Digest* digest) { |
| MD5Context ctx; |
| MD5Init(&ctx); |
| - MD5Update(&ctx, static_cast<const unsigned char*>(data), length); |
| + MD5Update(&ctx, |
| + StringPiece(reinterpret_cast<const char*>(data), length)); |
| MD5Final(digest, &ctx); |
| } |
| -std::string MD5String(const std::string& str) { |
| +std::string MD5String(const StringPiece& str) { |
| MD5Digest digest; |
| MD5Sum(str.data(), str.length(), &digest); |
| return MD5DigestToBase16(digest); |