# How do you encrypt URLs of pages?

**URL:** <https://www.ruby-forum.com/t/how-do-you-encrypt-urls-of-pages/142302>\
**Category:** Rails\
**Created:** [July 6, 2008, 2:31pm UTC](https://www.ruby-forum.com/t/how-do-you-encrypt-urls-of-pages/142302 "2008-07-06T14:31:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [July 6, 2008, 2:31pm UTC](https://www.ruby-forum.com/t/how-do-you-encrypt-urls-of-pages/142302/1 "2008-07-06T14:31:12Z")

</div>

I saw that [Box.net](http://Box.net) does this for their shared pages:

[http://www.box.net/shared/7g4q7pnok4](http://www.box.net/shared/7g4q7pnok4)

instead of the usual:

[http://www.box.net/shared/12345](http://www.box.net/shared/12345)

I Googled for the last hour, but still haven’t found out how to encrypt  
URLs. Maybe I’m searching for the wrong terms.

Any ideas on how to “encrypt” URLs?

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [July 6, 2008, 2:52pm UTC](https://www.ruby-forum.com/t/how-do-you-encrypt-urls-of-pages/142302/2 "2008-07-06T14:52:25Z")

</div>

add an encrypted/hashed attribute on your model [and db]. then use  
that attribute in the routing instead of id.

map.encrypted “/shared/:encrypted\_attribute”, :controller =\>  
“some\_controller”, :action =\> “some\_action”

HTH

RSL
