Encryption using the XOR logical operator
This logical operator (XOR) seems to tell everything, but doesn’t really tell anything until you have the right key. You will understand this better if you know what this operator means. It is a binary operator. The result of this operator on two inputs A and B is described in the below table:

What this means is that the output is 1 only when both inputs are different. But in any case you cannot tell which input was 1 and which was 0. In case of a 1 output (where both inputs are the same) you cannot tell weather they were both 0 or both 1.Application in Encryption

Let us say that we want to encrypt the bit A. So we will select the bit B as a particular key(in this case, either 0 or 1), XOR it with the bit A, and the result is our encrypted bit for A. Without B, there is no way except brute-force (which in this case will take just 2 trials), to tell the value of A with 100% surety. This may seem worthless, as the encryption was broken so easily by brute-force, but consider a more realistic example of a file of 1MB (1024 * 1024 * 8 bits) encrypted by a 48 bit key (any six lettered word). It will take a brute-force attack 2^48 or 281474976710656 trials to decrypt the text. This number will keep growing exponentially with each bit added to the key. Feeling better now?<>/span

Decryption Scheme

The beauty of encryption with XOR is that the method of decryption is exactly the same as the method of encryption. This is explained by the below table:

As you can see, the values of (A XOR B) and B, taken from the first table, when XORed together, give back the column A of the first table. So, to decrypt the cypher-text, all we need to do is XOR it with the key again, and the result is the plain-text.

Leave a comment

I’m Prashant

With over two decades of experience in technology leadership, cloud strategy, and digital transformation, I have had the privilege of working with some of the most dynamic enterprises, including Amazon, Wipro and ThoughtFocus. From modernizing legacy systems to enabling AI-driven innovations, I thrive at the intersection of technology and business.

This blog is my space to share insights, experiences, and lessons learned from my career in cloud computing, digital transformation, and enterprise technology. I aim to break down complex topics into actionable strategies for technology leaders, professionals, and enthusiasts alike.

Let’s connect