Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6118007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:23:10+00:00 2026-05-23T15:23:10+00:00

Given I’ve got a site where most of the resources have numerical IDs (i.e.

  • 0

Given I’ve got a site where most of the resources have numerical IDs (i.e. user.id question.id etc.) but that like the Germans looking back on WWII I’d rather not reveal these to the observers, what’s the best way to obfuscate them?

I presume the method is going to involve the .to_param and then some symmetric encryption algorithm but I’m not sure what’s the most efficient encryption to do and how it’ll impact lookup times in the DB etc.

Any advice from the road trodden would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:23:11+00:00Added an answer on May 23, 2026 at 3:23 pm

    I usually use a salted Hash and store it in the DB in an indexed field. It depends on the level of security you expect, but I use one salt for all.

    This method makes the creation a bit more expensive, because you are going to have an INSERT and an UPDATE, but your lookups will be quite fast.

    Pseudo code:

    class MyModel << ActiveRecord::Base
    
      MY_SALT = 'some secret string'
    
      after_create :generate_hashed_id
    
      def to_param
        self.hashed_id
      end
    
      def generate_hashed_id
        self.update_attributes(:hashed_id => Digest::SHA1.hexdigest("--#{MY_SALT}--#{self.id}--"))
      end
    
    end
    

    Now you can look up the record with MyModel.find_by_hashed_id(params[:id]) without any performance repercussions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this: $ids = ''; I just realized that this: $single = $ids ==
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Given that I have the array Let Sum be 16 dintptr = { 0
Given a table like this, what query will the most recent calibration information for
Given a collection that I want to arrange on a page like this: <!--
Given long long int x, y; , I want a function that can compare
Given a page like What popular startup advice is plain wrong? , I'd like
Given is an online swf on Hubworld's site, which loads two configuration XMLs into
Given SQL Server 2008, I have written a simple find in string function as
Given a tree, how to find the centre node in the tree so that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.