File: //opt/alt/ruby32/share/gems/doc/base64-0.3.0/ri/Base64/cdesc-Base64.ri
U:RDoc::NormalModule[iI"Base64:ET@0o:RDoc::Markup::Document:@parts[o;;[Bo:RDoc::Markup::Paragraph;[I"*\Module \Base64 provides methods for:;To:RDoc::Markup::BlankLine o:RDoc::Markup::List:
@type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o; ;[I"A\Encoding a binary string (containing non-ASCII characters) ;TI"/as a string of printable ASCII characters.;To;;0;[o; ;[I"%Decoding such an encoded string.;T@o; ;[I"<\Base64 is commonly used in contexts where binary data ;TI"!is not allowed or supported:;T@o;;;
;[o;;0;[o; ;[I"-Images in HTML or CSS files, or in URLs.;To;;0;[o; ;[I"Email attachments.;T@o; ;[I"IA \Base64-encoded string is about one-third larger that its source. ;TI"GSee the {Wikipedia article}[https://en.wikipedia.org/wiki/Base64] ;TI"for more information.;T@o; ;[I"@This module provides three pairs of encode/decode methods. ;TI"7Your choices among these methods should depend on:;T@o;;;
;[o;;0;[o; ;[I"AWhich character set is to be used for encoding and decoding.;To;;0;[o; ;[I"%Whether "padding" is to be used.;To;;0;[o; ;[I"5Whether encoded strings are to contain newlines.;T@o; ;[I"PNote: Examples on this page assume that the including program has executed:;T@o:RDoc::Markup::Verbatim;[I"require 'base64'
;T:@format0S:RDoc::Markup::Heading:
leveli: textI"\Encoding Character Sets;T@o; ;[I"RA \Base64-encoded string consists only of characters from a 64-character set:;T@o;;;
;[
o;;0;[o; ;[I"<tt>('A'..'Z')</tt>.;To;;0;[o; ;[I"<tt>('a'..'z')</tt>.;To;;0;[o; ;[I"<tt>('0'..'9')</tt>.;To;;0;[o; ;[I")<tt>=</tt>, the 'padding' character.;To;;0;[o; ;[I"Either:;To;;;
;[o;;0;[o; ;[I"<tt>%w[+ /]</tt>: ;TI"J{RFC-2045-compliant}[https://datatracker.ietf.org/doc/html/rfc2045]; ;TI"_not_ safe for URLs.;To;;0;[o; ;[I"<tt>%w[- _]</tt>: ;TI"J{RFC-4648-compliant}[https://datatracker.ietf.org/doc/html/rfc4648]; ;TI"safe for URLs.;T@o; ;[I"IIf you are working with \Base64-encoded strings that will come from ;TI"For be put into URLs, you should choose this encoder-decoder pair ;TI"#of RFC-4648-compliant methods:;T@o;;;
;[o;;0;[o; ;[I"9Base64.urlsafe_encode64 and Base64.urlsafe_decode64.;T@o; ;[I"@Otherwise, you may choose any of the pairs in this module, ;TI"?including the pair above, or the RFC-2045-compliant pairs:;T@o;;;
;[o;;0;[o; ;[I")Base64.encode64 and Base64.decode64.;To;;0;[o; ;[I"7Base64.strict_encode64 and Base64.strict_decode64.;T@S;;i;I"Padding;T@o; ;[I"7\Base64-encoding changes a triplet of input bytes ;TI")into a quartet of output characters.;T@o; ;[I"%<b>Padding in Encode Methods</b>;T@o; ;[I"LPadding -- extending an encoded string with zero, one, or two trailing ;TI"G<tt>=</tt> characters -- is performed by methods Base64.encode64, ;TI"FBase64.strict_encode64, and, by default, Base64.urlsafe_encode64:;T@o;;[ I"@Base64.encode64('s') # => "cw==\n"
;TI">Base64.strict_encode64('s') # => "cw=="
;TI">Base64.urlsafe_encode64('s') # => "cw=="
;TI"<Base64.urlsafe_encode64('s', padding: false) # => "cw"
;T;0o; ;[I"TWhen padding is performed, the encoded string is always of length <em>4n</em>, ;TI")where +n+ is a non-negative integer:;T@o;;;
;[o;;0;[o; ;[I"KInput bytes of length <em>3n</em> generate unpadded output characters ;TI"of length <em>4n</em>:;T@o;;[ I"(# n = 1: 3 bytes => 4 characters.
;TI"4Base64.strict_encode64('123') # => "MDEy"
;TI"(# n = 2: 6 bytes => 8 characters.
;TI"8Base64.strict_encode64('123456') # => "MDEyMzQ1"
;T;0o;;0;[o; ;[I"KInput bytes of length <em>3n+1</em> generate padded output characters ;TI"Gof length <em>4(n+1)</em>, with two padding characters at the end:;T@o;;[ I"(# n = 1: 4 bytes => 8 characters.
;TI"8Base64.strict_encode64('1234') # => "MDEyMw=="
;TI")# n = 2: 7 bytes => 12 characters.
;TI"<Base64.strict_encode64('1234567') # => "MDEyMzQ1Ng=="
;T;0o;;0;[o; ;[I"KInput bytes of length <em>3n+2</em> generate padded output characters ;TI"Fof length <em>4(n+1)</em>, with one padding character at the end:;T@o;;[ I"(# n = 1: 5 bytes => 8 characters.
;TI"8Base64.strict_encode64('12345') # => "MDEyMzQ="
;TI")# n = 2: 8 bytes => 12 characters.
;TI"<Base64.strict_encode64('12345678') # => "MDEyMzQ1Njc="
;T;0o; ;[I"CWhen padding is suppressed, for a positive integer <em>n</em>:;T@o;;;
;[o;;0;[o; ;[I"KInput bytes of length <em>3n</em> generate unpadded output characters ;TI"of length <em>4n</em>:;T@o;;[ I"(# n = 1: 3 bytes => 4 characters.
;TI"EBase64.urlsafe_encode64('123', padding: false) # => "MDEy"
;TI"(# n = 2: 6 bytes => 8 characters.
;TI"IBase64.urlsafe_encode64('123456', padding: false) # => "MDEyMzQ1"
;T;0o;;0;[o; ;[I"MInput bytes of length <em>3n+1</em> generate unpadded output characters ;TI"Eof length <em>4n+2</em>, with two padding characters at the end:;T@o;;[ I"(# n = 1: 4 bytes => 6 characters.
;TI"GBase64.urlsafe_encode64('1234', padding: false) # => "MDEyMw"
;TI")# n = 2: 7 bytes => 10 characters.
;TI"KBase64.urlsafe_encode64('1234567', padding: false) # => "MDEyMzQ1Ng"
;T;0o;;0;[o; ;[I"MInput bytes of length <em>3n+2</em> generate unpadded output characters ;TI"Dof length <em>4n+3</em>, with one padding character at the end:;T@o;;[ I"(# n = 1: 5 bytes => 7 characters.
;TI"HBase64.urlsafe_encode64('12345', padding: false) # => "MDEyMzQ"
;TI")# m = 2: 8 bytes => 11 characters.
;TI"LBase64.urlsafe_encode64('12345678', padding: false) # => "MDEyMzQ1Njc"
;T;0o; ;[I"%<b>Padding in Decode Methods</b>;T@o; ;[I"LAll of the \Base64 decode methods support (but do not require) padding.;T@o; ;[I"D\Method Base64.decode64 does not check the size of the padding:;T@o;;[I"4Base64.decode64("MDEyMzQ1Njc") # => "01234567"
;TI"5Base64.decode64("MDEyMzQ1Njc=") # => "01234567"
;TI"6Base64.decode64("MDEyMzQ1Njc==") # => "01234567"
;T;0o; ;[I"C\Method Base64.strict_decode64 strictly enforces padding size:;T@o;;[I"DBase64.strict_decode64("MDEyMzQ1Njc") # Raises ArgumentError
;TI"=Base64.strict_decode64("MDEyMzQ1Njc=") # => "01234567"
;TI"DBase64.strict_decode64("MDEyMzQ1Njc==") # Raises ArgumentError
;T;0o; ;[I"K\Method Base64.urlsafe_decode64 allows padding in the encoded string, ;TI"(which if present, must be correct: ;TI"Csee {Padding}[Base64.html#module-Base64-label-Padding], above:;T@o;;[I"<Base64.urlsafe_decode64("MDEyMzQ1Njc") # => "01234567"
;TI"=Base64.urlsafe_decode64("MDEyMzQ1Njc=") # => "01234567"
;TI"FBase64.urlsafe_decode64("MDEyMzQ1Njc==") # Raises ArgumentError.
;T;0S;;i;I"
Newlines;T@o; ;[I"NAn encoded string returned by Base64.encode64 or Base64.urlsafe_encode64 ;TI"'has an embedded newline character ;TI"Eafter each 60-character sequence, and, if non-empty, at the end:;T@o;;[I"# No newline if empty.
;TI",encoded = Base64.encode64("\x00" * 0)
;TI""encoded.index("\n") # => nil
;TI"
;TI"'# Newline at end of short output.
;TI",encoded = Base64.encode64("\x00" * 1)
;TI" encoded.size # => 4
;TI" encoded.index("\n") # => 4
;TI"
;TI"(# Newline at end of longer output.
;TI",encoded = Base64.encode64("\x00" * 45)
;TI"!encoded.size # => 60
;TI"!encoded.index("\n") # => 60
;TI"
;TI"<# Newlines embedded and at end of still longer output.
;TI",encoded = Base64.encode64("\x00" * 46)
;TI"3encoded.size # => 65
;TI"3encoded.rindex("\n") # => 65
;TI"8encoded.split("\n").map {|s| s.size } # => [60, 4]
;T;0o; ;[I";The string to be encoded may itself contain newlines, ;TI""which are encoded as \Base64:;T@o;;[I"3 # Base64.encode64("\n\n\n") # => "CgoK\n"
;TI",s = "This is line 1\nThis is line 2\n"
;TI"IBase64.encode64(s) # => "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK\n";T;0:
@fileI"lib/base64.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[ [U:RDoc::Constant[i I"VERSION;TI"Base64::VERSION;T:public0o;;[ ;@@;0@@@cRDoc::NormalModule0[ [[I"
class;T[[;[ [:protected[ [:private[ [I"
instance;T[[;[[I"
decode64;TI"lib/base64.rb;T[I"
encode64;T@\[I"strict_decode64;T@\[I"strict_encode64;T@\[I"urlsafe_decode64;T@\[I"urlsafe_encode64;T@\[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[@@@@cRDoc::TopLevel