Method 1: Divide by 2 Shortcut (Most Common and Easiest)
Divide the number by 2.
Example: Convert 13 to binary
Division | Quotient | Remainder |
---|---|---|
13 ÷ 2 | 6 | 1 |
6 ÷ 2 | 3 | 0 |
3 ÷ 2 | 1 | 1 |
1 ÷ 2 | 0 | 1 |
When the quotient is 0, stop.
Now read remainders from bottom to top:
So, 13 (decimal) = 1101 (binary)
Method 2: Tip for Small Numbers (Head Method):
You can memorize powers of 2:
Power of 2 | Value |
---|---|
2⁷ | 128 |
2⁶ | 64 |
2⁵ | 32 |
2⁴ | 16 |
2³ | 8 |
2² | 4 |
2¹ | 2 |
2⁰ | 1 |
Example: Convert 19 to binary using powers of 2
Write it:
What is Vernam Cipher?
HELLO
XMCKL
EQNVZ
.Vernam Cipher (Using XOR)
Bit P | Bit K | Result (C = P ⊕ K) |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
So, XOR flips bits when the key bit = 1, and keeps bits the same when the key bit = 0.
How it Works (Step by Step)
A=0, B=1, …, Z=25
).Here’s the full mapping table:
A = 0 (00000) B = 1 (00001) C = 2 (00010) D = 3 (00011)
E = 4 (00100) F = 5 (00101) G = 6 (00110) H = 7 (00111)
I = 8 (01000) J = 9 (01001) K = 10 (01010) L = 11 (01011)
M = 12(01100) N = 13(01101) O = 14(01110) P = 15(01111)
Q = 16(10000) R = 17(10001) S = 18(10010) T = 19(10011)
U = 20(10100) V = 21(10101) W = 22(10110) X = 23(10111)
Y = 24(11000) Z = 25(11001)
Each letter is represented in 5 bits.
Example 1
Example 2:
Summary