Results 1 to 8 of 8

- August 1st 2007, 01:36 AM #1

- Joined
- Aug 2007
- Posts
- 11

## Xor

Hi! I am actually a PHP programmer Not a Maths Guy .

I was making a strong Xor encryption function. While doing that I wondered on this three numbers (10, 20, 30).Code:10 Xor 20 Xor 30 Xor S results S

Code:10 Xor S Xor 30 Xor 20 results S

- August 1st 2007, 03:34 AM #2

- Joined
- Nov 2005
- From
- someplace
- Posts
- 14,972
- Thanks
- 5

- August 1st 2007, 03:53 AM #3

- Joined
- Aug 2007
- Posts
- 11

- August 1st 2007, 04:38 AM #4

- Joined
- Nov 2005
- From
- someplace
- Posts
- 14,972
- Thanks
- 5

Are you sure that 10: 1010 rather than 00001010?

and what about S?

xor(00010100,00011110)=00001010

so:

xor(xor(00010100,00011110),00001010)=00000000

(binary add without carry, also I have set them to a field width of 8 bits which realy does not make a lot of difference but may well be what the machine is doing)

RonL

- August 1st 2007, 05:11 AM #5

- Joined
- Aug 2007
- Posts
- 11

- August 1st 2007, 06:28 AM #6

- Joined
- Aug 2007
- Posts
- 11

Well I've simplified my Problem

Code:10 Xor 20 Xor 30 is 0

Code:0 Xor S results S

10 Xor 20 = 30

10Xor 30 = 20

20 Xor 30 = 10

...................................

In a Cyclick order.

And I think If an Expression with Xor results 0 it means

Say a Xor b Xor c Xor d Xor e ........ = 0

then

b Xor c Xor d Xor e ........ = a

a Xor c Xor d Xor e ........ = b

....................................

e.g. Xor of all other element must be equal to the 1(or more Xored) rest element(s)

e.g. if its a Xor b Xor c Xor d = 0

a Xor c = b Xor d

a Xor d = b Xor d

and so on.

- August 1st 2007, 10:22 AM #7

- Joined
- Nov 2005
- From
- someplace
- Posts
- 14,972
- Thanks
- 5

Each bit of the multiple xor is 1 if there are an odd number of bits set in that

bit position and zero otherwise. There are an even number of bits set in each

position in 10, 20 and 30, so when xor-ed with any bit pattern in any order

the result has the same bit pattern as the extra bit pattern.

Alternate explanation is that xor is both associative and comultative so the

order of xor-s does not matter, so as 10 xor 20 xor 30 = 0 the result follows.

RonL

- August 2nd 2007, 06:06 AM #8

- Joined
- Aug 2007
- Posts
- 11