Ruby 1.9 introduced a nice addition to the Base64 module: Base64.strict_encode64. Whereas Base64.encode64 prettifies its output with newlines, Base64.strict_encode64 yields output without any superfluous line feeds.

s = 'a' * 64
puts Base64.encode64 s
# >> YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh
# >> YWFhYWFhYWFhYWFhYWFhYWFhYQ==
puts Base64.strict_encode64 s
# >> YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ==

This is a nice feature if you find yourself in need of RFC 4648-compliant output. You need this, for example, if you are generating policy documents for a form which uploads directly to Amazon S3. In such a scenario, instead of sending #gsub to the output of encode64 to strip out line feeds you can simply call strict_encode64.