| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/sha1.h" | 5 #include <stddef.h> |
| 6 #include <string> |
| 6 | 7 |
| 7 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 8 | 9 |
| 9 namespace base { | 10 namespace base { |
| 10 | 11 |
| 11 // Implementation of SHA-1. Only handles data in byte-sized blocks, | 12 // Implementation of SHA-1. Only handles data in byte-sized blocks, |
| 12 // which simplifies the code a fair bit. | 13 // which simplifies the code a fair bit. |
| 13 | 14 |
| 14 // Identifier names follow notation in FIPS PUB 180-3, where you'll | 15 // Identifier names follow notation in FIPS PUB 180-3, where you'll |
| 15 // also find a description of the algorithm: | 16 // also find a description of the algorithm: |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 std::string SHA1HashString(const std::string& str) { | 193 std::string SHA1HashString(const std::string& str) { |
| 193 SecureHashAlgorithm sha; | 194 SecureHashAlgorithm sha; |
| 194 sha.Update(str.c_str(), str.length()); | 195 sha.Update(str.c_str(), str.length()); |
| 195 sha.Final(); | 196 sha.Final(); |
| 196 std::string out(reinterpret_cast<const char*>(sha.Digest()), | 197 std::string out(reinterpret_cast<const char*>(sha.Digest()), |
| 197 SecureHashAlgorithm::kDigestSizeBytes); | 198 SecureHashAlgorithm::kDigestSizeBytes); |
| 198 return out; | 199 return out; |
| 199 } | 200 } |
| 200 | 201 |
| 201 } // namespace base | 202 } // namespace base |
| OLD | NEW |