|
| 01 Jun 2009 09:07 PM |
Why is XOR so popular for encryption and decryption scripts? I've never bothered to learn it so, yea... I know it's an exclusive or, but how so? Do we have a XOR in lua? |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2009 09:11 PM |
Umm... i think it's pointless to learn, but here's how it works.
it basically means if-this-but-not-that *OR* if-that-but-not-this
basically:
if (cond1)~=(cond2) then --cond1 = condition1, cond2 = condition2 end
I think I took that example from anam or x on another thread. |
|
|
| Report Abuse |
|
|
Meelo
|
  |
| Joined: 04 Jul 2008 |
| Total Posts: 14763 |
|
|
| 01 Jun 2009 09:12 PM |
Say ^ is XOR (Like in most languages)
true^true = false^true = true true^false = true^false = true false^true = true^true = false false^false = false^false = false
a^b=c c^b=a
It natrually goes both ways. |
|
|
| Report Abuse |
|
|
dsds2
|
  |
| Joined: 21 May 2008 |
| Total Posts: 3851 |
|
|
| 02 Jun 2009 10:51 AM |
It's great for simple stream ciphers:
Encrypt --- key = 10 plaintxt = 01 key^plaintxt = 11
Decrypt --- key = 10 ciphertxt = 11 key^ciphertxt = 01 |
|
|
| Report Abuse |
|
|
sdfgw
|
  |
 |
| Joined: 08 Jan 2009 |
| Total Posts: 41681 |
|
|
| 02 Jun 2009 11:03 AM |
Really SIMPLY, let's use binary.
Say you were adding A (which is 100101010) and B (which is 00101001). It works like this:
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0
So:
100101010 + 001010011 = ------------- 101010001
And if you add the add A to this, you get B.
101010001+ 100101010= ------------- 001010011
AND if you add B to your answer istead, guess what?
101010001+ 001010011= ------------- 100101010
You get A! So if you wanted to encode A, you invent B, and use it to get C: the code. To decode it, simply use B again.
How is this useful? Well replace 0 with false and 1 with true and then.......... well, I have no idea. |
|
|
| Report Abuse |
|
|
mattscy
|
  |
| Joined: 06 May 2011 |
| Total Posts: 1079 |
|
|
| 05 Nov 2017 07:46 AM |
this may be the oldest scripting post you can reply to
the history is real |
|
|
| Report Abuse |
|
|
|
| 05 Nov 2017 07:56 AM |
"true^true = false^true = true" I want to go back to '09 and criticise this guy. That statement is wrong. And if nothing else, his post is ridiculously hard to follow.
true and false = false and false Yeah, that whole thing I just said is false. It makes sense, in a way, but it should never ever be said.
|
|
|
| Report Abuse |
|
|