XOR already provides perfect security in theory but it's hard to apply it in practice due to strict requirements. I was thinking about whether simple addition/subtraction in integer format would not be more practical to use while also providing perfect secrecy.
- "9" will be the plaintext and "1" will be the secret key. In ASCII/UTF-8 they both occupy 1 byte of space, so qualified to xor-ing, so that is 8 bits.
- 9 = 00111001
- 1 = 00110001
First we would XOR like normally one would do, so:
Encipher: 00111001 ⊕ 00110001 = 00001000
(obviously the output will be junk ciphertext, in this case the "Back Space" key in ASCII)
Decipher: 00001000 ⊕ 00110001 = 00111001
Or we would use addition for encipher and subtraction for decipher in integer format:
Encipher: 9 + 1 = 10
Decipher: 10 - 1 = 9
As you can see it's just as forwardly secure as XOR-ing, the 10 doesn't reveal anything about the 9, since the key and the plaintext can be both a gigantic positive and negative number who's sum is just happens to be 10, so it provides perfect secrecy.
It's also easier to use, you don't have to convert to binary.
But it has 1 special attribute that I think it makes it superior to XOR. Look at the binary value of 10, it's
0011000100110000, it's 2 bytes long.
So using addition/subtraction instead of XOR also hides and obfuscates the length of the plaintext, doesn't it? Because if we use integers, we are not using a bitwise operation anymore.
Instead the key can be any length, nobody can determine whether we have 9+1=10 or 1000000000+(-999999990)=10 or any other infinite number of combinations. It totally obfuscates the size of the data, there is no correlation between plaintext size and ciphertext size.
And since it's not bitwise operation anymore, it doesn't have the "leakage" problem that XOR has, the key length can be any size, and it doesn't even have to be true random (I think, correct me if I am wrong), any pseudo-random and sufficiently complex integer can do it.
So I think this makes it superior to XOR and other bitwise operators.
Why isn't integer addition used in encryption algorithms? What do you think about this encryption method? Is it better and more practical than XOR?