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

Side by Side Diff: base/base64.cc

Issue 399068: Move base64 from 'net/base' into 'base'. (Closed)
Patch Set: rebase Created 11 years 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 | « base/base64.h ('k') | base/base64_unittest.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) 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 4
5 #include "net/base/base64.h" 5 #include "base/base64.h"
6 6
7 #include "third_party/modp_b64/modp_b64.h" 7 #include "third_party/modp_b64/modp_b64.h"
8 8
9 namespace net { 9 namespace base {
10 10
11 bool Base64Encode(const std::string& input, std::string* output) { 11 bool Base64Encode(const std::string& input, std::string* output) {
12 std::string temp; 12 std::string temp;
13 temp.resize(modp_b64_encode_len(input.size())); // makes room for null byte 13 temp.resize(modp_b64_encode_len(input.size())); // makes room for null byte
14 14
15 // null terminates result since result is base64 text! 15 // null terminates result since result is base64 text!
16 int input_size = static_cast<int>(input.size()); 16 int input_size = static_cast<int>(input.size());
17 int output_size= modp_b64_encode(&(temp[0]), input.data(), input_size); 17 int output_size= modp_b64_encode(&(temp[0]), input.data(), input_size);
18 if (output_size < 0) 18 if (output_size < 0)
19 return false; 19 return false;
(...skipping 11 matching lines...) Expand all
31 int input_size = static_cast<int>(input.size()); 31 int input_size = static_cast<int>(input.size());
32 int output_size = modp_b64_decode(&(temp[0]), input.data(), input_size); 32 int output_size = modp_b64_decode(&(temp[0]), input.data(), input_size);
33 if (output_size < 0) 33 if (output_size < 0)
34 return false; 34 return false;
35 35
36 temp.resize(output_size); 36 temp.resize(output_size);
37 output->swap(temp); 37 output->swap(temp);
38 return true; 38 return true;
39 } 39 }
40 40
41 } // namespace net 41 } // namespace base
OLDNEW
« no previous file with comments | « base/base64.h ('k') | base/base64_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698