Pseudorandom numbers from the 32-bit INTEGER auto increment

I have a table with a 32-bit integer primary key with automatic increment in the database, which will produce numbers in the range 1-4294967295.

I would like to keep the convenience of the automatically generated primary key, and my numbers in the application interface look randomly.

Is there a mathematical function that would allow one-to-one two-way conversion between an integer and another ?

For example, a function will take a number and translate it into another:

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

And one more function back:

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

I don’t have to look for an implementation here, but rather a hint that I assume there should be a known math problem somewhere :)

+3
3

, .

: id ( ) ( ) . : ( ) () .

, , , ?

, , "" . 32- ( ) . 32- . . , .

, - , / , , , .

+6

1, 0 2 32 -2. m = 2 32 -1.

a, m. , ', a * a' = 1 (mod m). b. , .

y = (a * x + b) % m x = ((y - b) * a') % m.

(LCG) .

, , . , , a b.

+2

- . .

, , .

0

All Articles