On Wed, Mar 26, 2008 at 8:13 PM, Trans <transfire / gmail.com> wrote:
> Hi,
>
>  I need to take an arbitrary byte string and encode it as alphanumeric
>  (and decode it back again). Any pointers on a easy way to do this?
>
>  Thanks,
>  T.
>
Here's one way:

require 'base64'

str = Base64.encode64('\0\1')
# =>  "XDBcMQ==\n"
Base64.decode64(str)
# =>  "\\0\\1"

HTH
Sean