Method: Base64.decode64

Defined in:
lib/base64.rb

.decode64(str) ⇒ Object

Returns a string containing the decoding of an RFC-2045-compliant Base64-encoded string str:

s = "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK\n"
Base64.decode64(s) # => "This is line 1\nThis is line 2\n"

Non-Base64 characters in str are ignored; see Encoding Character Set above: these include newline characters and characters - and /:

Base64.decode64("\x00\n-_") # => ""

Padding in str (even if incorrect) is ignored:

Base64.decode64("MDEyMzQ1Njc")   # => "01234567"
Base64.decode64("MDEyMzQ1Njc=")  # => "01234567"
Base64.decode64("MDEyMzQ1Njc==") # => "01234567"


241
242
243
# File 'lib/base64.rb', line 241

def decode64(str)
  str.unpack1("m")
end