1

I have come across 2 versions of otp while reading it and want to confirm it.

  1. they have taken a plain text consisting of alphabets where they are shifted and replaced by alphabets itself.

  2. XORing of binary I/P streams with binary key.

Are they both valid forms? When I/P is in alphabets, shouldn't we convert it into binary form and then perform XORing with key?

SEJPM
  • 46,697
  • 9
  • 103
  • 214
CuriousCurie
  • 103
  • 5

2 Answers2

2

According to the definition on Wikipedia, both are valid uses of the term "one time pad" - "each bit or character of the plaintext is encrypted by combining it with the corresponding bit or character from the pad using modular addition." - that is: e=(d+p)%m, where e=encrypted data, d=decrypted data (input), p=pad, m is the number of possible values in e, d, and p (which must be the same). % is modulus - divide (d+p) by m, but take the remainder.

The most common implementation is the XOR method, which is the above calculation using m=2 (since 1 bit has two different possible values). A byte-by-byte solution would be equally valid, with m=256. letter by letter (m=26) is fine PROVIDED only encrypted data is sent - if you use this but send punctuation, capitals, newlines, and spaces unencrypted (or encrypted as a separate character set, then this is no longer secure (it will leak data - e.g. word lengths, and position and likely candidates for proper nouns, etc.).

Remember also, the pad needs to be really, really random, and of the same length (at least) as the message. It can never be reused. If the pad is English text, it is very insecure.

0

Here is how to make a Caesar Shift Cipher work with a One-Time Pad.

First you write your message down:

"ABCD"

Then instead of shifting the alphabet for the whole message. You shift the alphabet for each letter based on a number in your pad.

"13, 3, 11, 0"

So in this case:

For A you shift the alphabet 13 times to get N.

B you shift the alphabet 3 times in the same direction to get E.

C is shifted 13 times to get P.

And finally D is shifted 0 times to remain at D.

So our coded message is NEPD

Note: The alphabet is reset back to its normal position for each shift.

You can also include the other characters and numbers in this scheme to. Also you can chose the starting position for the alphabet too.

WAR10CK
  • 189
  • 5