--0022150482bb4df648048e389de5 Content-Type: text/plain; charset=ISO-8859-1 it's cool! thx Clifford :) On Fri, Aug 20, 2010 at 9:25 AM, Clifford Heath <no / spam.please.net> wrote: > Chuck Remes wrote: > >> On Aug 19, 2010, at 11:19 AM, Cyril.Liu wrote: >> >>> But the string is too long for me, i want to encode it with base64. >>> Is any clever way to do this? >>> >> If anything, base64 encoding will make it *longer*. >> > > Not if he converts it to binary first. > > Here's one I made earlier, not base64 though; this is base91. > It turns UUIDs into 20 printable ASCII bytes. > You can change the reference string to whatever you like. > I use sysuuid (gem install it), but you make get uuids elsewhere. > > require 'sysuuid' > > class Integer > def base(b) > self < b ? [self] : (self/b).base(b) + [self%b] > end > end > > # If we only used upper, lower and digits (base 62), it'd need 22 > characters and be more easily copy-pastable > BASE91 > '!#$%&()*+,-./0123456789:;<