| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // A class for encrypting/decrypting strings | 4 // A class for encrypting/decrypting strings |
| 5 | 5 |
| 6 #ifndef CHROME_BROWSER_ENCRYPTOR_H__ | 6 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_ENCRYPTOR_H__ |
| 7 #define CHROME_BROWSER_ENCRYPTOR_H__ | 7 #define CHROME_BROWSER_PASSWORD_MANAGER_ENCRYPTOR_H__ |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "base/string16.h" |
| 12 | 13 |
| 13 class Encryptor { | 14 class Encryptor { |
| 14 public: | 15 public: |
| 15 // Encrypt a wstring. The output (second argument) is | 16 // Encrypt a string16. The output (second argument) is |
| 16 // really an array of bytes, but we're passing it back | 17 // really an array of bytes, but we're passing it back |
| 17 // as a std::string | 18 // as a std::string |
| 18 static bool EncryptWideString(const std::wstring& plaintext, | 19 static bool EncryptString16(const string16& plaintext, |
| 19 std::string* ciphertext); | 20 std::string* ciphertext); |
| 20 | 21 |
| 21 // Decrypt an array of bytes obtained with EnctryptWideString | 22 // Decrypt an array of bytes obtained with EncryptString16 |
| 22 // back into a wstring. Note that the input (first argument) | 23 // back into a string16. Note that the input (first argument) |
| 23 // is a std::string, so you need to first get your (binary) | 24 // is a std::string, so you need to first get your (binary) |
| 24 // data into a string. | 25 // data into a string. |
| 25 static bool DecryptWideString(const std::string& ciphertext, | 26 static bool DecryptString16(const std::string& ciphertext, |
| 26 std::wstring* plaintext); | 27 string16* plaintext); |
| 27 | 28 |
| 28 // Encrypt a string. | 29 // Encrypt a string. |
| 29 static bool EncryptString(const std::string& plaintext, | 30 static bool EncryptString(const std::string& plaintext, |
| 30 std::string* ciphertext); | 31 std::string* ciphertext); |
| 31 | 32 |
| 32 // Decrypt an array of bytes obtained with EnctryptString | 33 // Decrypt an array of bytes obtained with EnctryptString |
| 33 // back into a string. Note that the input (first argument) | 34 // back into a string. Note that the input (first argument) |
| 34 // is a std::string, so you need to first get your (binary) | 35 // is a std::string, so you need to first get your (binary) |
| 35 // data into a string. | 36 // data into a string. |
| 36 static bool DecryptString(const std::string& ciphertext, | 37 static bool DecryptString(const std::string& ciphertext, |
| 37 std::string* plaintext); | 38 std::string* plaintext); |
| 38 | 39 |
| 39 private: | 40 private: |
| 40 DISALLOW_IMPLICIT_CONSTRUCTORS(Encryptor); | 41 DISALLOW_IMPLICIT_CONSTRUCTORS(Encryptor); |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 #endif // CHROME_BROWSER_ENCRYPTOR_H__ | 44 #endif // CHROME_BROWSER_PASSWORD_MANAGER_ENCRYPTOR_H__ |
| 44 | |
| OLD | NEW |