End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Base64#encode64
encode64(bin)
lib/base64.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/base64.rb, line 38
def encode64(bin)
[bin].pack("m")
end
Returns the Base64-encoded version of bin. This method complies with RFC 2045. Line feeds are added to every 60 encoded characters.
Example
require 'base64' Base64.encode64("Now is the time for all good coders\nto learn Ruby")
Generates:
Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g UnVieQ==