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.
5 #ifndef BASE_BASE64URL_H_
6 #define BASE_BASE64URL_H_
10 #include "base/base_export.h"
11 #include "base/strings/string_piece.h"
15 enum class Base64UrlEncodePolicy {
16 // Include the trailing padding in the output, when necessary.
19 // Remove the trailing padding from the output.
23 // Encodes the |input| string in base64url, defined in RFC 4648:
24 // https://tools.ietf.org/html/rfc4648#section-5
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,
32 enum class Base64UrlDecodePolicy {
33 // Require inputs contain trailing padding if non-aligned.
36 // Accept inputs regardless of whether or not they have the correct padding.
39 // Reject inputs if they contain any trailing padding.
43 // Decodes the |input| string in base64url, defined in RFC 4648:
44 // https://tools.ietf.org/html/rfc4648#section-5
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,
54 #endif // BASE_BASE64URL_H_