Producing URL friendly encoded params?

Hi folks. Looking for a simple, yet face-punchingly evasive bit of
functionality. Basically, I want to encrypt/decrypt an action
parameter, such as:

I feel I have the hard part done, in the form of a small crypto
library. This lib has a couple methods that Base64 pack the value,
des3 encrypts it, then CGI.escapes the output. The decrypter does all
that in reverse.

This works most of the time, but I encountered an issue where the
output sporadically contains a period, which destroys restful routing.
So I was hoping to find a cleaner encoding of the value, I suppose
similar to the Rails session value, that has zero potential for
dangerous characters. I'm thinking this is a hex conversion back and
forth, but the specifics elude me.

Any advice mucho appreciated. Cheers.