Hello! I need your help in solving one problem.
There are three variables:

$ a = 16431130;
$ b = 15318085;
$ c = 8860504;
$ result = $ a ^ $ b ^ c;

At the end, two values ​​are known, the $ result variable and the $ c variable. Tell me how to get the variables $ a and $ b from these 2 variables. How best to change
$ result = $ a ^ $ b ^ c;
to get the desired result?

  • one
    Obviously no way to get it. - Alexey Ten
  • no options at all? - user235655
  • one
    a = 1, b = 2, c = 3, r = 0 or a = 0, b = 3, c = 3, r = 0. You only know c and r. Which option do you want to get? - Alexey Ten
  • $a = rand(); $b = $a ^ $c ^ $result; - Akina
  • I advise you to read about the resistance of gammirovaniya - Arnial

2 answers 2

Apparently you want to crack the Code of Vernam . It is used by the military to transmit beyond secret information and without knowing the key it cannot be hacked. If it works out - write here - you will make an invaluable contribution to cryptography. In your case, you can only get the result $ a ^ $ b like this:

 function myXor($c,$result){ return $result^$c; } 
  • one
    maybe you can do without xor? Can you have any formulas so that you can convert the result from the 3 variables $ a, $ b, $ c? - user235655
  • one
    dear user235655, the result of $ a ^ $ b can be an exponential number of answers - I will explain what I mean, you got 0 for 1 and 1, and also 0 and 0 ;;; you got 1 for it fits 0 and 1, and also fits 1 and 0 ;;; you get 01 for this fits 01 and 00, as well as 10 and 11, as well as 11 and 10 ... If you want to randomly 2 any numbers $ a and $ b - rewrite the question. If you want to find out the number of matching $ a and $ b number of options, then change the question. Otherwise, you close this question - the answer to it is given and proven. - Mcile

How best to change ...

You can store a and b in different bits.

 $result = ($a << 32 | $b) ^ $c; 

Here is the code:

 $a = 12345; $b = 65432; $c = 723648723; $res = ($a << 32 | $b) ^ $c; $ab = $res ^ $c; $b = ($res ^ $c) % (1 << 32) | 0; $a = ($res ^ $c) / (1 << 32) | 0; var_dump([$a, $b]); 

Result:

 array(2) { [0]=> int(12345) [1]=> int(65432) } 

Unfortunately, if $c not large enough, $a will be displayed in the clear. You must select $c as a random 64bit number. $a and $b in turn, are limited to the 32bit range.