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

Side by Side Diff: components/webdata/encryptor/encryptor_posix.cc

Issue 13973004: Convert string16 -> base::string16 in components/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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 "components/webdata/encryptor/encryptor.h" 5 #include "components/webdata/encryptor/encryptor.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "crypto/encryptor.h" 10 #include "crypto/encryptor.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 salt, 47 salt,
48 kEncryptionIterations, 48 kEncryptionIterations,
49 kDerivedKeySizeInBits)); 49 kDerivedKeySizeInBits));
50 DCHECK(encryption_key.get()); 50 DCHECK(encryption_key.get());
51 51
52 return encryption_key.release(); 52 return encryption_key.release();
53 } 53 }
54 54
55 } // namespace 55 } // namespace
56 56
57 bool Encryptor::EncryptString16(const string16& plaintext, 57 bool Encryptor::EncryptString16(const base::string16& plaintext,
58 std::string* ciphertext) { 58 std::string* ciphertext) {
59 return EncryptString(UTF16ToUTF8(plaintext), ciphertext); 59 return EncryptString(UTF16ToUTF8(plaintext), ciphertext);
60 } 60 }
61 61
62 bool Encryptor::DecryptString16(const std::string& ciphertext, 62 bool Encryptor::DecryptString16(const std::string& ciphertext,
63 string16* plaintext) { 63 base::string16* plaintext) {
64 std::string utf8; 64 std::string utf8;
65 if (!DecryptString(ciphertext, &utf8)) 65 if (!DecryptString(ciphertext, &utf8))
66 return false; 66 return false;
67 67
68 *plaintext = UTF8ToUTF16(utf8); 68 *plaintext = UTF8ToUTF16(utf8);
69 return true; 69 return true;
70 } 70 }
71 71
72 bool Encryptor::EncryptString(const std::string& plaintext, 72 bool Encryptor::EncryptString(const std::string& plaintext,
73 std::string* ciphertext) { 73 std::string* ciphertext) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 std::string iv(kIVBlockSizeAES128, ' '); 130 std::string iv(kIVBlockSizeAES128, ' ');
131 crypto::Encryptor encryptor; 131 crypto::Encryptor encryptor;
132 if (!encryptor.Init(encryption_key.get(), crypto::Encryptor::CBC, iv)) 132 if (!encryptor.Init(encryption_key.get(), crypto::Encryptor::CBC, iv))
133 return false; 133 return false;
134 134
135 if (!encryptor.Decrypt(raw_ciphertext, plaintext)) 135 if (!encryptor.Decrypt(raw_ciphertext, plaintext))
136 return false; 136 return false;
137 137
138 return true; 138 return true;
139 } 139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698