# Producing URL friendly encoded params?

**URL:** <https://www.ruby-forum.com/t/producing-url-friendly-encoded-params/175101>\
**Category:** Rails\
**Created:** [September 8, 2009, 1:40am UTC](https://www.ruby-forum.com/t/producing-url-friendly-encoded-params/175101 "2009-09-08T01:40:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![uberllama](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/a587f6/32.png) [@uberllama](https://www.ruby-forum.com/u/uberllama)\
**Post date:** [September 8, 2009, 1:40am UTC](https://www.ruby-forum.com/t/producing-url-friendly-encoded-params/175101/1 "2009-09-08T01:40:41Z")

</div>

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

[foo.com/users/encodedvalue/action](http://foo.com/users/encodedvalue/action)

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.
