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

  • Home
  • SEARCH
  • 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 6011195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:13:29+00:00 2026-05-23T02:13:29+00:00

I have a table with an auto-increment 32-bit integer primary key in a database,

  • 0

I have a table with an auto-increment 32-bit integer primary key in a database, which will produce numbers ranging 1-4294967295.

I would like to keep the convenience of an auto-generated primary key, while having my numbers on the front-end of an application look like randomly generated.

Is there a mathematical function which would allow a two-way, one-to-one transformation between an integer and another?

For example a function would take a number, and translate it to another:

1 => 1538645623
2 => 2043145593
3 =>  393439399

And another function the way back:

1538645623 => 1
2043145593 => 2
 393439399 => 3

I’m not necessarily looking for an implementation here, but rather a hint on what I suppose, must be a well-known mathematical problem somewhere 🙂

  • 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-23T02:13:30+00:00Added an answer on May 23, 2026 at 2:13 am

    Mathematically this is almost exactly the same problem as cryptography.

    You: I want to go from an id(string of bits) to another number (string of bits) and back again in a non-obvious way.
    Cryptography: I want to go from plaintext (string of bits) to another string of bits and back again (reversible) in a non-obvious way.

    So for a simple solution, can I suggest just plugging in whatever cryptography algorithm is most convenient in your language, and encrypt and decrypt your id?

    If you wanted to be a bit cleverer you can do what is called “salting” in addition to cryptography. Take your id as a 32 bit (or whatever) number. Concatenate it with a random 32 bit number. Encrypt the result. To reverse, just decrypt, and throw away the random part.

    Of course, if someone was seriously attacking this, this might be vulnerable to known plaintext/differential cryptanalysis attacks as you have a very small known plaintext space, but it sounds like you aren’t trying to defend against serious attacks.

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

Sidebar

Related Questions

I have a table with a primary key that is auto increment. I want
I have table with following structure id int auto increment, primary key uid int
Was a bit suprised today to discover that my auto-increment primary key still gets
I have table with an auto-increment field, but I need to transfer the table
In MySql I could have a table with an auto increment column and insert
I have a table of web pages, with the primary key as hash of
I have a MySQL table with a primary key field that has AUTO_INCREMENT on.
I have a MySql table whose primary key is a 64bit BigInt I'm using
I have the following bit of PHP code, which creates three database tables, then
I have table that doesn't need a specific field to be the primary key.

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.