base64.h 918 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (c) 2011 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. #ifndef BASE_BASE64_H_
  5. #define BASE_BASE64_H_
  6. #include <string>
  7. #include "base/base_export.h"
  8. #include "base/containers/span.h"
  9. #include "base/strings/string_piece.h"
  10. namespace base {
  11. // Encodes the input binary data in base64.
  12. BASE_EXPORT std::string Base64Encode(span<const uint8_t> input);
  13. // Encodes the input string in base64.
  14. BASE_EXPORT void Base64Encode(const StringPiece& input, std::string* output);
  15. // Decodes the base64 input string. Returns true if successful and false
  16. // otherwise. The output string is only modified if successful. The decoding can
  17. // be done in-place.
  18. BASE_EXPORT bool Base64Decode(const StringPiece& input, std::string* output);
  19. } // namespace base
  20. #endif // BASE_BASE64_H_