From: "t3ch.dude" Date: 2008-03-27T06:24:56+09:00 Subject: Re: Encode as alphanumeric On Mar 26, 4:44 pm, Trans wrote: > On Mar 26, 4:27 pm, MenTaLguY wrote: > > > On Thu, 27 Mar 2008 05:13:23 +0900, Trans wrote: > > > 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? > > > What sort of encoding do you have in mind?  Hexadecimal?  Base64? > > I'm using a two-way encryption algorithm to create a registration key. > The encryption algorithm produces an arbitrary byte string. I need to > encode that into something I can give to a end-user, ie. an > alphanumeric string. > > Base64 is close but not quite [a-zA-Z0-9]. > > T. How about a proper subset [a-f0-9] ? irb(main):001:0> readable = "\0\1ALf\3=".unpack('H*') => ["0001414c66033d"] irb(main):002:0> original = readable.pack('H*') => "\000\001ALf\003=" -T3ch.dude