On Mar 26, 4:44  殮
> On Mar 26, 4:27 pm, MenTaLguY <men... / rydia.net> wrote:
>
> > On Thu, 27 Mar 2008 05:13:23 +0900, Trans <transf... / gmail.com> 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?   嶴
>
> 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