6

I was playing with the Vernam cipher on some online converter.
But when I tried to encrypt my message string with numbers, it remained unchanged.
Moreover, it was ignoring numbers and was encrypting as some alphabet appears in the key.

enter image description here

So, can we use numbers as a pad in the Vernam cipher - why or why not?

Mashhood
  • 161
  • 3

2 Answers2

5

Yes, you can use numbers as a one-time-pad key. In fact, the CIA used to do it all the time, as did many.

When you use numbers the plaintext becomes letters by referring to a conversion table such as the venerable "Tapir" used by the STASI.

TAPIR card example

Here the addition will be modulo 10. Vernam Cipher, or the one-time pad (OTP), can also be done modulo 2:

SENDING
-------
message: 0 0 1 0 1 1 0 1 0 1 1 1 ...
pad:     1 0 0 1 1 1 0 0 1 0 1 1 ...
XOR      ---------------------------
cipher:  1 0 1 1 0 0 0 1 1 1 0 0 ...

RECEIVING
---------
cipher:  1 0 1 1 0 0 0 1 1 1 0 0 ...
pad:     1 0 0 1 1 1 0 0 1 0 1 1 ...
XOR      ---------------------------
message: 0 0 1 0 1 1 0 1 0 1 1 1 ...

Or, it can be done modulo 26 (with English letters). For example:

Plaintext:  DARLING THE NIST CURVES HAVE BEEN COMPROMISED AND MY RANDOM NUMBER GENERATOR HAS A KLEPTOGRAPHIC BACKDOOR I FEEL SAD
Key:        NLQVT ZBOFW MFAVS RJMDE PGNEX GGQMU VOFNE PBWXT ICDWK VEEYL EGVWS ZRDKD IDJGO HWKFF MBEGA KEUNQ BEYDO
---------------------------------------------------------------------------------------------------------------------------------
Ciphertext: QLHGB MHHMA ZNSOU LAHHW WGIIY KKDOI HDWBQ XTAAT VFPUB VRHMX RAHXW QXHXH ZDCUF OWCFP XFTZO QVUCX JGZDQ MUYBN VQUZE RBR

The reason you could not insert numbers into the online encrypt/decrypt tool you found is because that tool was only designed for the modulo 26 addition of letters.

Here is one example of what a CIA one-time-pad key looked like during the Cold War:

OTP numbers example

Patriot
  • 3,162
  • 3
  • 20
  • 66
4

The one-time pad operates on bits and bytes and is agnostic to what symbols those bytes represent, so, yes, you should be able to use numbers as well.

When it comes to the Vernam cipher the answer is "you should, but for some reason you can't". That reason is most likely the fact that, although Morse code does encode digits, they don't appear to be used with the cipher, as this picture from Wikipedia shows

ciphertext

This next bit isn't the most rigorous answer you'll find but it might do: At some point in Neal Stephenson's Cryptonomicon, the author took the time to describe how the main character, who wants to telegraph 3 using a one-time pad, changed that digit to THREE. All five letters are then encrypted. It's reasonable to assume Stephenson has done his homework.

Yet the Baudot code used later with Telex machines also supports digits; so the answer to your question Is it possible to use numbers as a key is For some historical reason you can't, and the website reproduces that behaviour.

But that is still conjecture on my part because the author of the tool you tried to use has to say the following:

// One-Time Pad

// This code was written by Tyler Akins and placed in the public domain.
// It would be nice if you left this header intact.  http://rumkin.com


// Implements a one-time pad for only alphabetic characters.  Preserves
// the character case in the text (not the key).
// encdec = -1 for decode, 1 for encode
// text = the text to encode or decode.
// key = the key (pad) to use
rath
  • 2,598
  • 3
  • 27
  • 40