method

b64encode

ruby latest stable - Class: Base64

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v1_8_7_330) is shown here.

b64encode(bin, len = 60)
public

Prints the Base64 encoded version of bin (a String) in lines of len (default 60) characters.

require 'base64'
data = "Now is the time for all good coders\nto learn Ruby" 
Base64.b64encode(data)

Generates:

Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
UnVieQ==

1Note

Use encode64!

grosser ยท Oct 17, 20081 thank

b64encode will print to the commandline, what a useful feature...