[M108 Migration][VD] Support set time and time zone offset
[platform/framework/web/chromium-efl.git] / base / base64url.h
1 // Copyright 2015 The Chromium Authors
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 BASE_BASE64URL_H_
6 #define BASE_BASE64URL_H_
7
8 #include <string>
9
10 #include "base/base_export.h"
11 #include "base/strings/string_piece.h"
12
13 namespace base {
14
15 enum class Base64UrlEncodePolicy {
16   // Include the trailing padding in the output, when necessary.
17   INCLUDE_PADDING,
18
19   // Remove the trailing padding from the output.
20   OMIT_PADDING
21 };
22
23 // Encodes the |input| string in base64url, defined in RFC 4648:
24 // https://tools.ietf.org/html/rfc4648#section-5
25 //
26 // The |policy| defines whether padding should be included or omitted from the
27 // encoded |*output|. |input| and |*output| may reference the same storage.
28 BASE_EXPORT void Base64UrlEncode(const StringPiece& input,
29                                  Base64UrlEncodePolicy policy,
30                                  std::string* output);
31
32 enum class Base64UrlDecodePolicy {
33   // Require inputs contain trailing padding if non-aligned.
34   REQUIRE_PADDING,
35
36   // Accept inputs regardless of whether or not they have the correct padding.
37   IGNORE_PADDING,
38
39   // Reject inputs if they contain any trailing padding.
40   DISALLOW_PADDING
41 };
42
43 // Decodes the |input| string in base64url, defined in RFC 4648:
44 // https://tools.ietf.org/html/rfc4648#section-5
45 //
46 // The |policy| defines whether padding will be required, ignored or disallowed
47 // altogether. |input| and |*output| may reference the same storage.
48 [[nodiscard]] BASE_EXPORT bool Base64UrlDecode(const StringPiece& input,
49                                                Base64UrlDecodePolicy policy,
50                                                std::string* output);
51
52 }  // namespace base
53
54 #endif  // BASE_BASE64URL_H_