It:
while(c) {
c &= c - 1;
d++;
}
counts the number of 1 bits per c. For example, if c = 10110, d will be 3.
It:
c = a ^ b;
a b. , 1-, a, b, , , a b, 1. :
101110 ^
011010
110100
, 1 a ^ b. , a = 0, b = number with d 1-bits.
d 1-, b = (2 to the power of d) - 1.
, d = 11, a = 0 b = (2 to the power of 11) - 1 = 2048 - 1 = 2047.
2 , :
2 to the power of k == 1 << k
, : encryption(a, b) == d if a = 0 and b = (1 << d) - 1.