> Yes, there's always: > > require 'base64' > Base64::encoe64(data) Actually that's deprecated in 1.9 afaik. Somebody else already pointed out that you can use Array#pack. > I'd love to hear suggestions to squeeze a few more characters out of it. Yours: c=('A'..'Z').to_a.join+('a'..'z').to_a.join+'0123456789+/' Mine (1.9 only): c=[*?A..?Z,*?a..?z,*?0..?9]*''+'+/' That's 23 characters. Yours: (t=s.unpack('C*').inject([0,'',0]){|a,v|a[0]==0?[2,a[1]+c[v>>2,1],v*16&48]:a[0]==2?[4,a[1]+c[v>>4|a[2],1],v*4&60]:[0,a[1]+c[v>>6|a[2],1]+c[v&63,1],0]})[1]+(t[0]==0?'':t[0]==2?c[t[2],1]+'==':c[t[2],1]+'=') Mine: (s.unpack("B*")[0]+'0'*((6-s.size*8%6)%6)).scan(/.{6}/).map{|e|c[e.to_i(2)]}*''+'='*((3-s.size%3)%3) That's another 104 characters off. So 127 characters less in total :) I also did only some very superficial tests, and mine doesn't insert newlines either. Though some clever gsub could do that easily. Regards & thanks for the challenge ;-) Stefan (aka apeiros) -- Sicherer, schneller und einfacher. Die aktuellen Internet-Browser - jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/atbrowser