I'm migrating a software made in Delphi to PHP and I came across a problem in a
fucking Blessed encryption function.
I suffered a bit trying to rewrite the function does the complexity of the code and with the differences in the results.
The function makes use of operators XOR and SHR in Delphi version. The SHR was relatively easy thanks to experience with bitwise operators and how Delphi documentation says that the operator pulls off bits to the right
Already the XOR operator was more complicated. PHP has this operator and I didn't work to make sure if both do the same thing. Only when I did some tests using different integers is I could realize that they do not give the same results. In Delphi it always returned a number while in PHP he returned 1 or 0 (actually true or false).
Only when I read the documentation of both languages I realized that are different. In Delphi XOR is a exclusive comparison operation (OR exclusive) which returns true or false Or a bitwise operation of two arguments. PHP is just a XOR operator to OR exclusive. He doesn't make the adjustments in bit operation. The equivalent in this case is the operator ^ (caret).
Another learning. Hope that helps someone else someday.
Follows some useful links.