XOR operator (^)
So what is it? The same as 8^3 == 8*8*8 == 512 ?
And what is the storry about XOR. Why is a class needed.
XOR operator (^)
So what is it? The same as 8^3 == 8*8*8 == 512 ?
And what is the storry about XOR. Why is a class needed.
Well english isn't my first language, (it's instead a useless language called danish which only 5 milion people speak!!) so if you think my grammar SUCKS (it does by the way) than you're more then welcome to correct me.
Hell I might even learn something
Xor is exclusive or. This is not the same as 4 raised to the 3 power. Say you want to xor the number 4 with the number 3. This is how it would look (the numbers are converted into binary)
0000 0100
xor
0000 0011
---------------
0000 0111 (7 in decimal form)
Basically, it is a comparison of bits. If both bits are 0 or 1 in the same spot, then the resulting bit for that spot will be 0. If only 1 of the bits are 1 and the other is 0, the resulting bit for that spot is 1.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
Does this kinda thing get used much? I know bitwise operation are fast, but in practice do they ever really get used?
Couldn't think of anything interesting, cool or funny - sorry.
>but in practice do they ever really get used?
In C, yes, quite a bit. In C++, not as much but for low level programming bit-wise operators are wonderful.
-Prelude
My best code is written with the delete key.
>I know bitwise operation are fast, but in practice do they ever really get used?
Yes, as Prelude mentioned, in low level applications, they are very useful, since in such applications you're working a lot with individual bits. Think about datacommunication. You receive telegram consisting of several bytes from a certain device, in such telegrams groups of bits and also individual bits can have a meaning.
But also think about encryption. The XOR is the base for one of the strongest, if not the strongest, encryption techniques, which is the One-Time-Pad. This is based on the property of XOR that:
plain_message ^ key = encrypted_message
encrypted_message ^ key = plain_message
The link I posted above details XOR encryption, along with strengths and weaknesses.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
I've read the site and would like to add something.
XOR encryption will be uncrackable if the key is as large or larger as the source. This is because then each key is a possible valid key and therefore the encrypted data is uncrackable.For most people's purposes, a key like "(Ta5!34hEf$" will suffice, but if you need extremely secure encryption, you can take the encrypted text, and XOR it with another key, or you could use a file's contents for the key.
>XOR encryption will be uncrackable if the key is as large or larger as the source. This is because then each key is a possible valid key and therefore the encrypted data is uncrackable.
I've edited the article to include this, and given you credit.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie