Encrypted ID in URLs
Posted
by Eric
on Stack Overflow
See other posts from Stack Overflow
or by Eric
Published on 2010-03-15T19:17:16Z
Indexed on
2010/03/15
19:19 UTC
Read the original article
Hit count: 131
ruby-on-rails
I am trying to hash or encrypt a record's ID for URL's such that people can't view various records simply by guessing different integer ID's.
Essentially, my URL's would be something like this: /plans/0AUTxwoGkOYfiZGd2 instead of /plans/304.
Would the best way to do this just be to use SHA-1 to hash the plan's id and store it in a hashed_id column for plans? Then, overwrite to_param and add a finder to find by hashed_id?
How do you ensure that the characters generated are 0-9, a-z, or A-Z?
Thanks!
© Stack Overflow or respective owner