怎么走出号码 - php [关闭]

I want to find out how I can extract $number out of the following code:

$calc = ($number % 10000) / 100;

So what's the opposite of %?

Generally you can't. % gives you the modulo of a division, there are mathematically an infinity of numbers that have the same modulo for a given ratio.

It is simply not bijective..

%, or the modulo operator, means "remainder after division by".

For example: 18 % 4 = 2, because if you divide 18 by 4 you get 4 with a remainder of 2. In the other direction, we can see that indeed 4 * 4 + 2 = 18.

Now consider the following:

18 % 4 = 2
22 % 4 = 2
26 % 4 = 2
...
2445678 % 4 = 2

As you can see, there are multiple values that are what we call congruent modulo 4. Therefore an inverse function of modulo cannot exist, because there is an infinite amount of possibilities.

Several cryptographic functions are based on the fact that the above holds true.