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

Side by Side Diff: crypto/sha2.cc

Issue 1870233002: Convert crypto to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 8 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 | « crypto/secure_hash_unittest.cc ('k') | crypto/signature_creator_nss.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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "crypto/sha2.h" 5 #include "crypto/sha2.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include <memory>
10
10 #include "base/stl_util.h" 11 #include "base/stl_util.h"
11 #include "crypto/secure_hash.h" 12 #include "crypto/secure_hash.h"
12 13
13 namespace crypto { 14 namespace crypto {
14 15
15 void SHA256HashString(const base::StringPiece& str, void* output, size_t len) { 16 void SHA256HashString(const base::StringPiece& str, void* output, size_t len) {
16 scoped_ptr<SecureHash> ctx(SecureHash::Create(SecureHash::SHA256)); 17 std::unique_ptr<SecureHash> ctx(SecureHash::Create(SecureHash::SHA256));
17 ctx->Update(str.data(), str.length()); 18 ctx->Update(str.data(), str.length());
18 ctx->Finish(output, len); 19 ctx->Finish(output, len);
19 } 20 }
20 21
21 std::string SHA256HashString(const base::StringPiece& str) { 22 std::string SHA256HashString(const base::StringPiece& str) {
22 std::string output(kSHA256Length, 0); 23 std::string output(kSHA256Length, 0);
23 SHA256HashString(str, string_as_array(&output), output.size()); 24 SHA256HashString(str, string_as_array(&output), output.size());
24 return output; 25 return output;
25 } 26 }
26 27
27 } // namespace crypto 28 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/secure_hash_unittest.cc ('k') | crypto/signature_creator_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698