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 7028227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:21:34+00:00 2026-05-28T00:21:34+00:00

I expect this’s been asked before but haven’t really found an appropriate answer here

  • 0

I expect this’s been asked before but haven’t really found an appropriate answer here and also don’t have the time to come up with my own solution…

If we have a user table with int identity primary key then our users have consecutive IDs while they register on the site.

The we have user public profile page on the site URL:

www.somesite.com/user/1234

where 1234 is the actual user ID. There is nothing vulnerable to see user’s ID per se, but it does give anyone the ability to check how many users are registered on my site… Manually increasing the number eventually gets me to an invalid profile.

This is the main reason why I wand a reversible ID mapping to a seemingly random number with fixed length:

www.somesite.com/user/6123978458176573

Can you point me to a simple class that does this mapping? It is of course important that this mapping is simply reversible otherwise I’d have to save the mapping along with other user’s data.

I want to avoid GUIDs

GUIDs are slower to index search them because they’re not consecutive so SQL has to scan the whole index to match a particular GUID instead just a particular calculated index page…

If I’d have ID + GUID then I would always need to fetch original user ID to do any meaningful data manipulation which is again speed degradation…

A mathematical reversible integer permutation seems the fastest solution…

  • 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-28T00:21:34+00:00Added an answer on May 28, 2026 at 12:21 am

    I would 100% go with the “Add a GUID column to the table” approach. It will take seconds to generate one for each current user, and update your insert procedure to generate one for each new user. This is the best solution.

    However, if you really dont want to take that approach there are any number of obfuscation techniques you could use.

    Simply Base64 encoding the string representation of your number is one (bad) way to do it.

        static public string EncodeTo64(string toEncode)
        {
    
          byte[] toEncodeAsBytes
                = System.Text.ASCIIEncoding.ASCII.GetBytes(toEncode);
          string returnValue
                = System.Convert.ToBase64String(toEncodeAsBytes);
          return returnValue;
        }
    
        static public string DecodeFrom64(string encodedData)
        {
          byte[] encodedDataAsBytes
              = System.Convert.FromBase64String(encodedData);
          string returnValue =
             System.Text.ASCIIEncoding.ASCII.GetString(encodedDataAsBytes);
          return returnValue;
        }
    

    Bad because anyone with half an ounce of technical knowledge (hackers/scriptkiddies tend to have that in abundance) will instantly recognise the result as Base64 and easily reverse-engineer.


    Edit: This blogpost Obfuscating IDs in URLs with Rails provides quite a workable example. Converting to C# gives you something like:

    static int Prime = 1580030173;
    static int PrimeInverse = 59260789;
    
    public static int EncodeId(int input)
    {
        return (input * Prime) & int.MaxValue;
    }
    
    public static int DecodeId(int input)
    {
        return (input * PrimeInverse) & int.MaxValue;
    }
    

    Input –> Output
    1234 –> 1989564746
    5678 –> 1372124598
    5679 –> 804671123

    This follow up post by another author explains how to secure this a little bit more with a random XOR, as well as how to calculate Prime and PrimeInverse – ive just used the pre-canned ones from the original blog for demo.

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

Sidebar

Related Questions

I don't expect a straightforward silver bullet answer to this, but what are the
This is a question that has been asked before, but unfortunately no solution seems
I'd expect this to be fairly routine, but cannot find a simple approach for
This might look like a basic question to some of you but I expect
Boy, this one is really weird. I expect the following code to print 1990,
I expect this is easy, but I'm not finding a simple explanation anywhere of
I expect this to work based on the docs here: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocSelectors.html SEL sel =
I strongly expect this to end up as a duplication, but I can't seem
I didn't expect this is that complex. But I can't figure out how I
Here is the JQuery extend page. What I would expect this to do is

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.