OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_BASE32_BASE32_H_ | 5 #ifndef BASE_BASE32_H_ |
6 #define COMPONENTS_BASE32_BASE32_H_ | 6 #define BASE_BASE32_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #include "base/base_export.h" |
10 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
11 | 12 |
12 namespace base32 { | 13 namespace base { |
13 | 14 |
14 enum class Base32EncodePolicy { | 15 enum class Base32EncodePolicy { |
15 // Include the trailing padding in the output, when necessary. | 16 // Include the trailing padding in the output, when necessary. |
16 INCLUDE_PADDING, | 17 INCLUDE_PADDING, |
17 // Omit trailing padding in the output. Such an output will not be decodable | 18 // Omit trailing padding in the output. Such an output will not be decodable |
18 // unless |input.size()| is known by the decoder. Its size is guaranteed to be | 19 // unless |input.size()| is known by the decoder. Its size is guaranteed to be |
19 // |ceil(input.size() * 8.0 / 5.0)|. | 20 // |ceil(input.size() * 8.0 / 5.0)|. |
20 OMIT_PADDING | 21 OMIT_PADDING |
21 }; | 22 }; |
22 | 23 |
23 // Encodes the |input| string in base32, defined in RFC 4648: | 24 // Encodes the |input| string in base32, defined in RFC 4648: |
24 // https://tools.ietf.org/html/rfc4648#section-5 | 25 // https://tools.ietf.org/html/rfc4648#section-5 |
25 // | 26 // |
26 // The |policy| defines whether padding should be included or omitted from the | 27 // The |policy| defines whether padding should be included or omitted from the |
27 // encoded output. | 28 // encoded output. |
28 std::string Base32Encode( | 29 BASE_EXPORT std::string Base32Encode( |
29 base::StringPiece input, | 30 StringPiece input, |
30 Base32EncodePolicy policy = Base32EncodePolicy::INCLUDE_PADDING); | 31 Base32EncodePolicy policy = Base32EncodePolicy::INCLUDE_PADDING); |
31 | 32 |
32 } // namespace base32 | 33 } // namespace base |
33 | 34 |
34 #endif // COMPONENTS_BASE32_BASE32_H_ | 35 #endif // BASE_BASE32_H_ |
OLD | NEW |