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 #include <vector> 10 11 #include "absl/strings/string_view.h" 12 #include "absl/types/span.h" 13 #include "platform/base/error.h" 14 15 namespace openscreen { 16 namespace base64 { 17 18 // Encodes the input binary data in base64. 19 std::string Encode(absl::Span<const uint8_t> input); 20 21 // Encodes the input string in base64. 22 std::string Encode(absl::string_view input); 23 24 // Decodes the base64 input string. Returns true if successful and false 25 // otherwise. The output string is only modified if successful. The decoding can 26 // be done in-place. 27 bool Decode(absl::string_view input, std::vector<uint8_t>* output); 28 29 } // namespace base64 30 } // namespace openscreen 31 32 #endif // UTIL_BASE64_H_ 33