Encrypted ID in URLs
- by Eric
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!