1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef UTIL_BASE64_H_
6 #define UTIL_BASE64_H_
7 
8 #include <string>
9 
10 #include "absl/strings/string_view.h"
11 #include "absl/types/span.h"
12 #include "platform/base/error.h"
13 
14 namespace openscreen {
15 namespace base64 {
16 
17 // Encodes the input binary data in base64.
18 std::string Encode(absl::Span<const uint8_t> input);
19 
20 // Encodes the input string in base64.
21 std::string Encode(absl::string_view input);
22 
23 // Decodes the base64 input string.  Returns true if successful and false
24 // otherwise. The output string is only modified if successful. The decoding can
25 // be done in-place.
26 bool Decode(absl::string_view input, std::string* output);
27 
28 }  // namespace base64
29 }  // namespace openscreen
30 
31 #endif  // UTIL_BASE64_H_
32