3
$\begingroup$

Is there any difference in adding the plain text and key vs using xor instead(apart from the performance improvements)?

$\endgroup$
9
  • $\begingroup$ If you do proper group addition, then there's no difference in security. $\endgroup$
    – SEJPM
    Commented Jan 18, 2016 at 20:08
  • $\begingroup$ I did it by adding the ascii values of the pt and k modulo 256 and haven't had problems so far. $\endgroup$
    – user30735
    Commented Jan 18, 2016 at 20:09
  • $\begingroup$ What "performance improvements", BTW? $\endgroup$
    – otus
    Commented Jan 18, 2016 at 20:09
  • $\begingroup$ I believe a computer can xor in one go which is faster than adding the values then using modulo. $\endgroup$
    – user30735
    Commented Jan 18, 2016 at 20:11
  • 1
    $\begingroup$ @otus, if you do it in assembly, XOR is much much faster than addition (which is implicetely performed $\bmod 2^{64}$) because for the CPU it's much simpler than this pesky addition with the carry and this stuff. And mod 256 is perfectly secure. $\endgroup$
    – SEJPM
    Commented Jan 18, 2016 at 20:18

1 Answer 1

6
$\begingroup$

There is no security difference; there are a handful of practical ones:

  • With xor, you can have the same code to do encryption and decryption

  • With xor, you don't have to pick a 'word size'; a larger CPU can handle 4 or 8 bytes at a time, while a microcontroller can handle 1 byte at a time, without changing the ciphertext

  • With xor, you don't have to worry about endianness (which you would if you, say, added words modulo $2^{32}$

While these are all minor differences, they all point towards xor being slightly better from a practical standpoint

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.