title: User ID obfuscation
body: <blockquote>
    <p>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...</p>
  </blockquote>
  
  <p>If we have a user table with <code>int identity</code> primary key then our users have consecutive IDs while they register on the site.</p>
  
  <p>The we have user public profile page on the site URL:</p>
  
  <pre><code>www.somesite.com/user/1234
  </code></pre>
  
  <p>where 1234 is the actual user ID. There is nothing vulnerable to see user's ID <em>per se</em>, 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.</p>
  
  <p>This is the main reason why I wand a reversible ID mapping to a seemingly random number with fixed length:</p>
  
  <pre><code>www.somesite.com/user/6123978458176573
  </code></pre>
  
  <p>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.</p>
  
  <h2>I want to avoid GUIDs</h2>
  
  <p>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...</p>
  
  <p>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...</p>
  
  <p>A mathematical reversible integer permutation seems the fastest solution...</p>