1/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15
16#ifndef TENSORFLOW_TSL_PLATFORM_BASE64_H_
17#define TENSORFLOW_TSL_PLATFORM_BASE64_H_
18
19#include <string>
20
21#include "tensorflow/tsl/platform/status.h"
22#include "tensorflow/tsl/platform/stringpiece.h"
23
24namespace tsl {
25
26/// \brief Converts data into web-safe base64 encoding.
27///
28/// See https://en.wikipedia.org/wiki/Base64
29template <typename T>
30Status Base64Encode(StringPiece source, bool with_padding, T* encoded);
31template <typename T>
32Status Base64Encode(StringPiece source,
33 T* encoded); // with_padding=false.
34
35/// \brief Converts data from web-safe base64 encoding.
36///
37/// See https://en.wikipedia.org/wiki/Base64
38template <typename T>
39Status Base64Decode(StringPiece data, T* decoded);
40
41// Explicit instantiations defined in base64.cc.
42extern template Status Base64Decode<std::string>(StringPiece data,
43 std::string* decoded);
44extern template Status Base64Encode<std::string>(StringPiece source,
45 std::string* encoded);
46extern template Status Base64Encode<std::string>(StringPiece source,
47 bool with_padding,
48 std::string* encoded);
49
50extern template Status Base64Decode<tstring>(StringPiece data,
51 tstring* decoded);
52extern template Status Base64Encode<tstring>(StringPiece source,
53 tstring* encoded);
54extern template Status Base64Encode<tstring>(StringPiece source,
55 bool with_padding,
56 tstring* encoded);
57
58} // namespace tsl
59
60#endif // TENSORFLOW_TSL_PLATFORM_BASE64_H_
61