# Add $1100+0110$ in binary

I'm studying encryption in class and we're doing "One-Time-Pad" encryption and I've come across this situation. I want to code $1100$, where my key is $0110$). In my book it says that the cipher is $1010$ - done through binary addition.

$$1100+0110=1010$$

but how does that make sense. In a $4$-bit system the numbers can only go to $2^4-1=15$ digits. So $1100+0110=10010$ ($12+6=18$). Am I missing something?

• Your calculations are correct. Please name and shame the book. – Rob Arthan Mar 17 '18 at 0:08
• One could say you got carried away (try adding without carry) – Dan Robertson Mar 17 '18 at 0:27

The usual encryption for a one-time pad is not addition, but the XOR (exclusive or) operation where you

1. line up the digits

2. If they're both one or both zero, they make a zero.

3. If one is zero and the other is one, they make a one

You can see that this is consistent with what your book has for the answer.

• This is the right answer. I’m not sure I really like saying “digitwise” as it implies that we are working with numbers when (most of the time) we’re actually working with vectors over $\Bbb F_2$. – Dan Robertson Mar 17 '18 at 0:16
• @DanRobertson True (I could have been fancier :)) – spaceisdarkgreen Mar 17 '18 at 0:18
• I only mention it because it’s obvious that the question came from either confusion about vectors vs numbers or about $+$ vs $\oplus$. – Dan Robertson Mar 17 '18 at 0:25

$$1100+0110=10010$$ is correct and as a result $$1100+0110=1010$$ is wrong.

Notice we are simply adding $$12+6=18$$ and not $$12+6= 10$$