Aaron D. Gifford wrote: >(...) > The shortest I've got it down to is 276 characters. WARNING: My email > client is gonna line-break this and mess it up. Just remove the > whitespace.) > > def > e(s);c=('A'..'Z').to_a.join+('a'..'z').to_a.join+'0123456789+/';(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]+'=');end >(...) > I'd love to hear suggestions to squeeze a few more characters out of it. > > Ideas? Suggestions? > > Having a bit too much fun fiddling with Ruby, > Aaron out. Heh, in ruby 1.9 you can do: c=(65..122).to_a.join(&:chr)+'0123456789+/' instead of c=(('A'..'Z').to_a|('a'..'z').to_a).join+'0123456789+/' hth, Siep -- Posted via http://www.ruby-forum.com/.