base64 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67c1752cf74c25682849d866ca527d3a001d52712144ec2d1b10df96389202f0
4
- data.tar.gz: 54196151956485052bcb6d58226490f4b30efa44fe75ace5d6e713b7a2154773
3
+ metadata.gz: da8017f88b13b4bcce299b2b4b5a3023ceca129259e34c96cf4ee8444651cb54
4
+ data.tar.gz: c13e817c37612d65668c7266945f2356982e090f0781d739cc9e2fbaadf5bad7
5
5
  SHA512:
6
- metadata.gz: 66de0c5435992cc15ba818a9d92e914edd777f09c535af68410fffe1a6485556ad85ec822e62b4b469e2614202b7f5aa7621f419a7ce9740ccb7c1c7da2ff70e
7
- data.tar.gz: b9ed3e456b9545f9e2aa8fba015730e9abe6345cfbebd013807314de9516df9e92896d31d081363f5b805f510617c8405785df7ddf8221d146b844c1208b6b3e
6
+ metadata.gz: 0c070995dc383eb45bb66d9b413eaf567434932477a4121834567c6deb5493c3498c652db0f23901696232ff098573db5b094f180c7ad2b90be189156f98e87e
7
+ data.tar.gz: a23bc57298678e16663a9a2f0007259437b8efe6c25d37481a2e47585b31229fdd9ff5dd76fb9f0618954e88d6a63d9f316a19d531ee7cbe6e9bea607ef859c5
@@ -4,10 +4,10 @@ Redistribution and use in source and binary forms, with or without
4
4
  modification, are permitted provided that the following conditions
5
5
  are met:
6
6
  1. Redistributions of source code must retain the above copyright
7
- notice, this list of conditions and the following disclaimer.
7
+ notice, this list of conditions and the following disclaimer.
8
8
  2. Redistributions in binary form must reproduce the above copyright
9
- notice, this list of conditions and the following disclaimer in the
10
- documentation and/or other materials provided with the distribution.
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
11
 
12
12
  THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
13
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
data/COPYING ADDED
@@ -0,0 +1,56 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a. place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b. use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c. give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d. make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a. distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b. accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c. give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d. make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/LEGAL ADDED
@@ -0,0 +1,60 @@
1
+ # -*- rdoc -*-
2
+
3
+ = LEGAL NOTICE INFORMATION
4
+ --------------------------
5
+
6
+ All the files in this distribution are covered under either the Ruby's
7
+ license (see the file COPYING) or public-domain except some files
8
+ mentioned below.
9
+
10
+ == MIT License
11
+ >>>
12
+ Permission is hereby granted, free of charge, to any person obtaining
13
+ a copy of this software and associated documentation files (the
14
+ "Software"), to deal in the Software without restriction, including
15
+ without limitation the rights to use, copy, modify, merge, publish,
16
+ distribute, sublicense, and/or sell copies of the Software, and to
17
+ permit persons to whom the Software is furnished to do so, subject to
18
+ the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be
21
+ included in all copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
+
31
+ == Old-style BSD license
32
+ >>>
33
+ Redistribution and use in source and binary forms, with or without
34
+ modification, are permitted provided that the following conditions
35
+ are met:
36
+ 1. Redistributions of source code must retain the above copyright
37
+ notice, this list of conditions and the following disclaimer.
38
+ 2. Redistributions in binary form must reproduce the above copyright
39
+ notice, this list of conditions and the following disclaimer in the
40
+ documentation and/or other materials provided with the distribution.
41
+ 3. Neither the name of the University nor the names of its contributors
42
+ may be used to endorse or promote products derived from this software
43
+ without specific prior written permission.
44
+
45
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55
+ SUCH DAMAGE.
56
+
57
+ IMPORTANT NOTE::
58
+
59
+ From ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
60
+ paragraph 3 above is now null and void.
data/lib/base64.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # \Module \Base64 provides methods for:
4
4
  #
5
- # - Encoding a binary string (containing non-ASCII characters)
5
+ # - \Encoding a binary string (containing non-ASCII characters)
6
6
  # as a string of printable ASCII characters.
7
7
  # - Decoding such an encoded string.
8
8
  #
@@ -27,7 +27,7 @@
27
27
  #
28
28
  # require 'base64'
29
29
  #
30
- # == Encoding Character Sets
30
+ # == \Encoding Character Sets
31
31
  #
32
32
  # A \Base64-encoded string consists only of characters from a 64-character set:
33
33
  #
@@ -140,7 +140,7 @@
140
140
  # Base64.strict_decode64("MDEyMzQ1Njc=") # => "01234567"
141
141
  # Base64.strict_decode64("MDEyMzQ1Njc==") # Raises ArgumentError
142
142
  #
143
- # \Method Base64.urlsafe_decode64 allows padding in +str+,
143
+ # \Method Base64.urlsafe_decode64 allows padding in the encoded string,
144
144
  # which if present, must be correct:
145
145
  # see {Padding}[Base64.html#module-Base64-label-Padding], above:
146
146
  #
@@ -183,11 +183,14 @@
183
183
  #
184
184
  module Base64
185
185
 
186
- VERSION = "0.2.0"
186
+ VERSION = "0.3.0"
187
187
 
188
188
  module_function
189
189
 
190
- # Returns a string containing the RFC-2045-compliant \Base64-encoding of +bin+.
190
+ # :call-seq:
191
+ # Base64.encode64(string) -> encoded_string
192
+ #
193
+ # Returns a string containing the RFC-2045-compliant \Base64-encoding of +string+.
191
194
  #
192
195
  # Per RFC 2045, the returned string may contain the URL-unsafe characters
193
196
  # <tt>+</tt> or <tt>/</tt>;
@@ -220,19 +223,22 @@ module Base64
220
223
  [bin].pack("m")
221
224
  end
222
225
 
226
+ # :call-seq:
227
+ # Base64.decode(encoded_string) -> decoded_string
228
+ #
223
229
  # Returns a string containing the decoding of an RFC-2045-compliant
224
- # \Base64-encoded string +str+:
230
+ # \Base64-encoded string +encoded_string+:
225
231
  #
226
232
  # s = "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK\n"
227
233
  # Base64.decode64(s) # => "This is line 1\nThis is line 2\n"
228
234
  #
229
- # Non-\Base64 characters in +str+ are ignored;
235
+ # Non-\Base64 characters in +encoded_string+ are ignored;
230
236
  # see {Encoding Character Set}[Base64.html#module-Base64-label-Encoding+Character+Sets] above:
231
237
  # these include newline characters and characters <tt>-</tt> and <tt>/</tt>:
232
238
  #
233
239
  # Base64.decode64("\x00\n-_") # => ""
234
240
  #
235
- # Padding in +str+ (even if incorrect) is ignored:
241
+ # Padding in +encoded_string+ (even if incorrect) is ignored:
236
242
  #
237
243
  # Base64.decode64("MDEyMzQ1Njc") # => "01234567"
238
244
  # Base64.decode64("MDEyMzQ1Njc=") # => "01234567"
@@ -242,7 +248,10 @@ module Base64
242
248
  str.unpack1("m")
243
249
  end
244
250
 
245
- # Returns a string containing the RFC-2045-compliant \Base64-encoding of +bin+.
251
+ # :call-seq:
252
+ # Base64.strict_encode64(string) -> encoded_string
253
+ #
254
+ # Returns a string containing the RFC-2045-compliant \Base64-encoding of +string+.
246
255
  #
247
256
  # Per RFC 2045, the returned string may contain the URL-unsafe characters
248
257
  # <tt>+</tt> or <tt>/</tt>;
@@ -274,13 +283,16 @@ module Base64
274
283
  [bin].pack("m0")
275
284
  end
276
285
 
286
+ # :call-seq:
287
+ # Base64.strict_decode64(encoded_string) -> decoded_string
288
+ #
277
289
  # Returns a string containing the decoding of an RFC-2045-compliant
278
- # \Base64-encoded string +str+:
290
+ # \Base64-encoded string +encoded_string+:
279
291
  #
280
292
  # s = "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK"
281
293
  # Base64.strict_decode64(s) # => "This is line 1\nThis is line 2\n"
282
294
  #
283
- # Non-\Base64 characters in +str+ not allowed;
295
+ # Non-\Base64 characters in +encoded_string+ are not allowed;
284
296
  # see {Encoding Character Set}[Base64.html#module-Base64-label-Encoding+Character+Sets] above:
285
297
  # these include newline characters and characters <tt>-</tt> and <tt>/</tt>:
286
298
  #
@@ -288,7 +300,7 @@ module Base64
288
300
  # Base64.strict_decode64('-') # Raises ArgumentError
289
301
  # Base64.strict_decode64('_') # Raises ArgumentError
290
302
  #
291
- # Padding in +str+, if present, must be correct:
303
+ # Padding in +encoded_string+, if present, must be correct:
292
304
  #
293
305
  # Base64.strict_decode64("MDEyMzQ1Njc") # Raises ArgumentError
294
306
  # Base64.strict_decode64("MDEyMzQ1Njc=") # => "01234567"
@@ -298,7 +310,10 @@ module Base64
298
310
  str.unpack1("m0")
299
311
  end
300
312
 
301
- # Returns the RFC-4648-compliant \Base64-encoding of +bin+.
313
+ # :call-seq:
314
+ # Base64.urlsafe_encode64(string) -> encoded_string
315
+ #
316
+ # Returns the RFC-4648-compliant \Base64-encoding of +string+.
302
317
  #
303
318
  # Per RFC 4648, the returned string will not contain the URL-unsafe characters
304
319
  # <tt>+</tt> or <tt>/</tt>,
@@ -332,16 +347,19 @@ module Base64
332
347
  str
333
348
  end
334
349
 
335
- # Returns the decoding of an RFC-4648-compliant \Base64-encoded string +str+:
350
+ # :call-seq:
351
+ # Base64.urlsafe_decode64(encoded_string) -> decoded_string
352
+ #
353
+ # Returns the decoding of an RFC-4648-compliant \Base64-encoded string +encoded_string+:
336
354
  #
337
- # +str+ may not contain non-Base64 characters;
355
+ # +encoded_string+ may not contain non-Base64 characters;
338
356
  # see {Encoding Character Set}[Base64.html#module-Base64-label-Encoding+Character+Sets] above:
339
357
  #
340
358
  # Base64.urlsafe_decode64('+') # Raises ArgumentError.
341
359
  # Base64.urlsafe_decode64('/') # Raises ArgumentError.
342
360
  # Base64.urlsafe_decode64("\n") # Raises ArgumentError.
343
361
  #
344
- # Padding in +str+, if present, must be correct:
362
+ # Padding in +encoded_string+, if present, must be correct:
345
363
  # see {Padding}[Base64.html#module-Base64-label-Padding], above:
346
364
  #
347
365
  # Base64.urlsafe_decode64("MDEyMzQ1Njc") # => "01234567"
data/sig/base64.rbs ADDED
@@ -0,0 +1,355 @@
1
+ # <!-- rdoc-file=lib/base64.rb -->
2
+ # Module Base64 provides methods for:
3
+ #
4
+ # * Encoding a binary string (containing non-ASCII characters) as a string of
5
+ # printable ASCII characters.
6
+ # * Decoding such an encoded string.
7
+ #
8
+ # Base64 is commonly used in contexts where binary data is not allowed or
9
+ # supported:
10
+ #
11
+ # * Images in HTML or CSS files, or in URLs.
12
+ # * Email attachments.
13
+ #
14
+ # A Base64-encoded string is about one-third larger that its source. See the
15
+ # [Wikipedia article](https://en.wikipedia.org/wiki/Base64) for more
16
+ # information.
17
+ #
18
+ # This module provides three pairs of encode/decode methods. Your choices among
19
+ # these methods should depend on:
20
+ #
21
+ # * Which character set is to be used for encoding and decoding.
22
+ # * Whether "padding" is to be used.
23
+ # * Whether encoded strings are to contain newlines.
24
+ #
25
+ # Note: Examples on this page assume that the including program has executed:
26
+ #
27
+ # require 'base64'
28
+ #
29
+ # ## Encoding Character Sets
30
+ #
31
+ # A Base64-encoded string consists only of characters from a 64-character set:
32
+ #
33
+ # * `('A'..'Z')`.
34
+ # * `('a'..'z')`.
35
+ # * `('0'..'9')`.
36
+ # * `=`, the 'padding' character.
37
+ # * Either:
38
+ # * `%w[+ /]`:
39
+ # [RFC-2045-compliant](https://datatracker.ietf.org/doc/html/rfc2045);
40
+ # *not* safe for URLs.
41
+ # * `%w[- _]`:
42
+ # [RFC-4648-compliant](https://datatracker.ietf.org/doc/html/rfc4648);
43
+ # safe for URLs.
44
+ #
45
+ # If you are working with Base64-encoded strings that will come from or be put
46
+ # into URLs, you should choose this encoder-decoder pair of RFC-4648-compliant
47
+ # methods:
48
+ #
49
+ # * Base64.urlsafe_encode64 and Base64.urlsafe_decode64.
50
+ #
51
+ # Otherwise, you may choose any of the pairs in this module, including the pair
52
+ # above, or the RFC-2045-compliant pairs:
53
+ #
54
+ # * Base64.encode64 and Base64.decode64.
55
+ # * Base64.strict_encode64 and Base64.strict_decode64.
56
+ #
57
+ # ## Padding
58
+ #
59
+ # Base64-encoding changes a triplet of input bytes into a quartet of output
60
+ # characters.
61
+ #
62
+ # **Padding in Encode Methods**
63
+ #
64
+ # Padding -- extending an encoded string with zero, one, or two trailing `=`
65
+ # characters -- is performed by methods Base64.encode64, Base64.strict_encode64,
66
+ # and, by default, Base64.urlsafe_encode64:
67
+ #
68
+ # Base64.encode64('s') # => "cw==\n"
69
+ # Base64.strict_encode64('s') # => "cw=="
70
+ # Base64.urlsafe_encode64('s') # => "cw=="
71
+ # Base64.urlsafe_encode64('s', padding: false) # => "cw"
72
+ #
73
+ # When padding is performed, the encoded string is always of length *4n*, where
74
+ # `n` is a non-negative integer:
75
+ #
76
+ # * Input bytes of length *3n* generate unpadded output characters of length
77
+ # *4n*:
78
+ #
79
+ # # n = 1: 3 bytes => 4 characters.
80
+ # Base64.strict_encode64('123') # => "MDEy"
81
+ # # n = 2: 6 bytes => 8 characters.
82
+ # Base64.strict_encode64('123456') # => "MDEyMzQ1"
83
+ #
84
+ # * Input bytes of length *3n+1* generate padded output characters of length
85
+ # *4(n+1)*, with two padding characters at the end:
86
+ #
87
+ # # n = 1: 4 bytes => 8 characters.
88
+ # Base64.strict_encode64('1234') # => "MDEyMw=="
89
+ # # n = 2: 7 bytes => 12 characters.
90
+ # Base64.strict_encode64('1234567') # => "MDEyMzQ1Ng=="
91
+ #
92
+ # * Input bytes of length *3n+2* generate padded output characters of length
93
+ # *4(n+1)*, with one padding character at the end:
94
+ #
95
+ # # n = 1: 5 bytes => 8 characters.
96
+ # Base64.strict_encode64('12345') # => "MDEyMzQ="
97
+ # # n = 2: 8 bytes => 12 characters.
98
+ # Base64.strict_encode64('12345678') # => "MDEyMzQ1Njc="
99
+ #
100
+ # When padding is suppressed, for a positive integer *n*:
101
+ #
102
+ # * Input bytes of length *3n* generate unpadded output characters of length
103
+ # *4n*:
104
+ #
105
+ # # n = 1: 3 bytes => 4 characters.
106
+ # Base64.urlsafe_encode64('123', padding: false) # => "MDEy"
107
+ # # n = 2: 6 bytes => 8 characters.
108
+ # Base64.urlsafe_encode64('123456', padding: false) # => "MDEyMzQ1"
109
+ #
110
+ # * Input bytes of length *3n+1* generate unpadded output characters of length
111
+ # *4n+2*, with two padding characters at the end:
112
+ #
113
+ # # n = 1: 4 bytes => 6 characters.
114
+ # Base64.urlsafe_encode64('1234', padding: false) # => "MDEyMw"
115
+ # # n = 2: 7 bytes => 10 characters.
116
+ # Base64.urlsafe_encode64('1234567', padding: false) # => "MDEyMzQ1Ng"
117
+ #
118
+ # * Input bytes of length *3n+2* generate unpadded output characters of length
119
+ # *4n+3*, with one padding character at the end:
120
+ #
121
+ # # n = 1: 5 bytes => 7 characters.
122
+ # Base64.urlsafe_encode64('12345', padding: false) # => "MDEyMzQ"
123
+ # # m = 2: 8 bytes => 11 characters.
124
+ # Base64.urlsafe_encode64('12345678', padding: false) # => "MDEyMzQ1Njc"
125
+ #
126
+ # **Padding in Decode Methods**
127
+ #
128
+ # All of the Base64 decode methods support (but do not require) padding.
129
+ #
130
+ # Method Base64.decode64 does not check the size of the padding:
131
+ #
132
+ # Base64.decode64("MDEyMzQ1Njc") # => "01234567"
133
+ # Base64.decode64("MDEyMzQ1Njc=") # => "01234567"
134
+ # Base64.decode64("MDEyMzQ1Njc==") # => "01234567"
135
+ #
136
+ # Method Base64.strict_decode64 strictly enforces padding size:
137
+ #
138
+ # Base64.strict_decode64("MDEyMzQ1Njc") # Raises ArgumentError
139
+ # Base64.strict_decode64("MDEyMzQ1Njc=") # => "01234567"
140
+ # Base64.strict_decode64("MDEyMzQ1Njc==") # Raises ArgumentError
141
+ #
142
+ # Method Base64.urlsafe_decode64 allows padding in `str`, which if present, must
143
+ # be correct: see [Padding](Base64.html#module-Base64-label-Padding), above:
144
+ #
145
+ # Base64.urlsafe_decode64("MDEyMzQ1Njc") # => "01234567"
146
+ # Base64.urlsafe_decode64("MDEyMzQ1Njc=") # => "01234567"
147
+ # Base64.urlsafe_decode64("MDEyMzQ1Njc==") # Raises ArgumentError.
148
+ #
149
+ # ## Newlines
150
+ #
151
+ # An encoded string returned by Base64.encode64 or Base64.urlsafe_encode64 has
152
+ # an embedded newline character after each 60-character sequence, and, if
153
+ # non-empty, at the end:
154
+ #
155
+ # # No newline if empty.
156
+ # encoded = Base64.encode64("\x00" * 0)
157
+ # encoded.index("\n") # => nil
158
+ #
159
+ # # Newline at end of short output.
160
+ # encoded = Base64.encode64("\x00" * 1)
161
+ # encoded.size # => 4
162
+ # encoded.index("\n") # => 4
163
+ #
164
+ # # Newline at end of longer output.
165
+ # encoded = Base64.encode64("\x00" * 45)
166
+ # encoded.size # => 60
167
+ # encoded.index("\n") # => 60
168
+ #
169
+ # # Newlines embedded and at end of still longer output.
170
+ # encoded = Base64.encode64("\x00" * 46)
171
+ # encoded.size # => 65
172
+ # encoded.rindex("\n") # => 65
173
+ # encoded.split("\n").map {|s| s.size } # => [60, 4]
174
+ #
175
+ # The string to be encoded may itself contain newlines, which are encoded as
176
+ # Base64:
177
+ #
178
+ # # Base64.encode64("\n\n\n") # => "CgoK\n"
179
+ # s = "This is line 1\nThis is line 2\n"
180
+ # Base64.encode64(s) # => "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK\n"
181
+ #
182
+ module Base64
183
+ # <!--
184
+ # rdoc-file=lib/base64.rb
185
+ # - decode64(str)
186
+ # -->
187
+ # Returns a string containing the decoding of an RFC-2045-compliant
188
+ # Base64-encoded string `str`:
189
+ #
190
+ # s = "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK\n"
191
+ # Base64.decode64(s) # => "This is line 1\nThis is line 2\n"
192
+ #
193
+ # Non-Base64 characters in `str` are ignored; see [Encoding Character
194
+ # Set](Base64.html#module-Base64-label-Encoding+Character+Sets) above: these
195
+ # include newline characters and characters `-` and `/`:
196
+ #
197
+ # Base64.decode64("\x00\n-_") # => ""
198
+ #
199
+ # Padding in `str` (even if incorrect) is ignored:
200
+ #
201
+ # Base64.decode64("MDEyMzQ1Njc") # => "01234567"
202
+ # Base64.decode64("MDEyMzQ1Njc=") # => "01234567"
203
+ # Base64.decode64("MDEyMzQ1Njc==") # => "01234567"
204
+ #
205
+ def self?.decode64: (String str) -> String
206
+
207
+ # <!--
208
+ # rdoc-file=lib/base64.rb
209
+ # - encode64(bin)
210
+ # -->
211
+ # Returns a string containing the RFC-2045-compliant Base64-encoding of `bin`.
212
+ #
213
+ # Per RFC 2045, the returned string may contain the URL-unsafe characters `+` or
214
+ # `/`; see [Encoding Character
215
+ # Set](Base64.html#module-Base64-label-Encoding+Character+Sets) above:
216
+ #
217
+ # Base64.encode64("\xFB\xEF\xBE") # => "++++\n"
218
+ # Base64.encode64("\xFF\xFF\xFF") # => "////\n"
219
+ #
220
+ # The returned string may include padding; see
221
+ # [Padding](Base64.html#module-Base64-label-Padding) above.
222
+ #
223
+ # Base64.encode64('*') # => "Kg==\n"
224
+ #
225
+ # The returned string ends with a newline character, and if sufficiently long
226
+ # will have one or more embedded newline characters; see
227
+ # [Newlines](Base64.html#module-Base64-label-Newlines) above:
228
+ #
229
+ # Base64.encode64('*') # => "Kg==\n"
230
+ # Base64.encode64('*' * 46)
231
+ # # => "KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq\nKg==\n"
232
+ #
233
+ # The string to be encoded may itself contain newlines, which will be encoded as
234
+ # ordinary Base64:
235
+ #
236
+ # Base64.encode64("\n\n\n") # => "CgoK\n"
237
+ # s = "This is line 1\nThis is line 2\n"
238
+ # Base64.encode64(s) # => "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK\n"
239
+ #
240
+ def self?.encode64: (String bin) -> String
241
+
242
+ # <!--
243
+ # rdoc-file=lib/base64.rb
244
+ # - strict_decode64(str)
245
+ # -->
246
+ # Returns a string containing the decoding of an RFC-2045-compliant
247
+ # Base64-encoded string `str`:
248
+ #
249
+ # s = "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK"
250
+ # Base64.strict_decode64(s) # => "This is line 1\nThis is line 2\n"
251
+ #
252
+ # Non-Base64 characters in `str` not allowed; see [Encoding Character
253
+ # Set](Base64.html#module-Base64-label-Encoding+Character+Sets) above: these
254
+ # include newline characters and characters `-` and `/`:
255
+ #
256
+ # Base64.strict_decode64("\n") # Raises ArgumentError
257
+ # Base64.strict_decode64('-') # Raises ArgumentError
258
+ # Base64.strict_decode64('_') # Raises ArgumentError
259
+ #
260
+ # Padding in `str`, if present, must be correct:
261
+ #
262
+ # Base64.strict_decode64("MDEyMzQ1Njc") # Raises ArgumentError
263
+ # Base64.strict_decode64("MDEyMzQ1Njc=") # => "01234567"
264
+ # Base64.strict_decode64("MDEyMzQ1Njc==") # Raises ArgumentError
265
+ #
266
+ def self?.strict_decode64: (String str) -> String
267
+
268
+ # <!--
269
+ # rdoc-file=lib/base64.rb
270
+ # - strict_encode64(bin)
271
+ # -->
272
+ # Returns a string containing the RFC-2045-compliant Base64-encoding of `bin`.
273
+ #
274
+ # Per RFC 2045, the returned string may contain the URL-unsafe characters `+` or
275
+ # `/`; see [Encoding Character
276
+ # Set](Base64.html#module-Base64-label-Encoding+Character+Sets) above:
277
+ #
278
+ # Base64.strict_encode64("\xFB\xEF\xBE") # => "++++\n"
279
+ # Base64.strict_encode64("\xFF\xFF\xFF") # => "////\n"
280
+ #
281
+ # The returned string may include padding; see
282
+ # [Padding](Base64.html#module-Base64-label-Padding) above.
283
+ #
284
+ # Base64.strict_encode64('*') # => "Kg==\n"
285
+ #
286
+ # The returned string will have no newline characters, regardless of its length;
287
+ # see [Newlines](Base64.html#module-Base64-label-Newlines) above:
288
+ #
289
+ # Base64.strict_encode64('*') # => "Kg=="
290
+ # Base64.strict_encode64('*' * 46)
291
+ # # => "KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg=="
292
+ #
293
+ # The string to be encoded may itself contain newlines, which will be encoded as
294
+ # ordinary Base64:
295
+ #
296
+ # Base64.strict_encode64("\n\n\n") # => "CgoK"
297
+ # s = "This is line 1\nThis is line 2\n"
298
+ # Base64.strict_encode64(s) # => "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK"
299
+ #
300
+ def self?.strict_encode64: (String bin) -> String
301
+
302
+ # <!--
303
+ # rdoc-file=lib/base64.rb
304
+ # - urlsafe_decode64(str)
305
+ # -->
306
+ # Returns the decoding of an RFC-4648-compliant Base64-encoded string `str`:
307
+ #
308
+ # `str` may not contain non-Base64 characters; see [Encoding Character
309
+ # Set](Base64.html#module-Base64-label-Encoding+Character+Sets) above:
310
+ #
311
+ # Base64.urlsafe_decode64('+') # Raises ArgumentError.
312
+ # Base64.urlsafe_decode64('/') # Raises ArgumentError.
313
+ # Base64.urlsafe_decode64("\n") # Raises ArgumentError.
314
+ #
315
+ # Padding in `str`, if present, must be correct: see
316
+ # [Padding](Base64.html#module-Base64-label-Padding), above:
317
+ #
318
+ # Base64.urlsafe_decode64("MDEyMzQ1Njc") # => "01234567"
319
+ # Base64.urlsafe_decode64("MDEyMzQ1Njc=") # => "01234567"
320
+ # Base64.urlsafe_decode64("MDEyMzQ1Njc==") # Raises ArgumentError.
321
+ #
322
+ def self?.urlsafe_decode64: (String str) -> String
323
+
324
+ # <!--
325
+ # rdoc-file=lib/base64.rb
326
+ # - urlsafe_encode64(bin, padding: true)
327
+ # -->
328
+ # Returns the RFC-4648-compliant Base64-encoding of `bin`.
329
+ #
330
+ # Per RFC 4648, the returned string will not contain the URL-unsafe characters
331
+ # `+` or `/`, but instead may contain the URL-safe characters `-` and `_`; see
332
+ # [Encoding Character
333
+ # Set](Base64.html#module-Base64-label-Encoding+Character+Sets) above:
334
+ #
335
+ # Base64.urlsafe_encode64("\xFB\xEF\xBE") # => "----"
336
+ # Base64.urlsafe_encode64("\xFF\xFF\xFF") # => "____"
337
+ #
338
+ # By default, the returned string may have padding; see
339
+ # [Padding](Base64.html#module-Base64-label-Padding), above:
340
+ #
341
+ # Base64.urlsafe_encode64('*') # => "Kg=="
342
+ #
343
+ # Optionally, you can suppress padding:
344
+ #
345
+ # Base64.urlsafe_encode64('*', padding: false) # => "Kg"
346
+ #
347
+ # The returned string will have no newline characters, regardless of its length;
348
+ # see [Newlines](Base64.html#module-Base64-label-Newlines) above:
349
+ #
350
+ # Base64.urlsafe_encode64('*') # => "Kg=="
351
+ # Base64.urlsafe_encode64('*' * 46)
352
+ # # => "KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg=="
353
+ #
354
+ def self?.urlsafe_encode64: (String bin, ?padding: boolish) -> String
355
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: base64
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Endoh
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-11-07 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Support for encoding and decoding binary data using a Base64 representation.
14
13
  email:
@@ -17,9 +16,12 @@ executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
20
- - LICENSE.txt
19
+ - BSDL
20
+ - COPYING
21
+ - LEGAL
21
22
  - README.md
22
23
  - lib/base64.rb
24
+ - sig/base64.rbs
23
25
  homepage: https://github.com/ruby/base64
24
26
  licenses:
25
27
  - Ruby
@@ -27,7 +29,7 @@ licenses:
27
29
  metadata:
28
30
  homepage_uri: https://github.com/ruby/base64
29
31
  source_code_uri: https://github.com/ruby/base64
30
- post_install_message:
32
+ changelog_uri: https://github.com/ruby/base64/releases
31
33
  rdoc_options: []
32
34
  require_paths:
33
35
  - lib
@@ -42,8 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
44
  - !ruby/object:Gem::Version
43
45
  version: '0'
44
46
  requirements: []
45
- rubygems_version: 3.5.0.dev
46
- signing_key:
47
+ rubygems_version: 3.6.7
47
48
  specification_version: 4
48
49
  summary: Support for encoding and decoding binary data using a Base64 representation.
49
50
  test_files: []