6
$\begingroup$

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?

$\endgroup$
3
  • 1
    $\begingroup$ I would find another resource to learn about cryptography. There is so much wrong in that image it hurts; the one-time pad is fundamentally uncrackable given that 1) the message and pad are of equal length, and 2) the pad is truly random, and 3) the pad is never reused. That's it. The bit about shorthand, abbreviations, and removing unnecessary letters is absolute nonsense. It's also not an actual implementation of a one-time pad, as it leaves valuable information like punctuation, numbers, and spaces unencrypted. Complete garbage. $\endgroup$ Commented Sep 12, 2014 at 16:24
  • $\begingroup$ where can i find the correct implementation in java code? do you have any idea? $\endgroup$
    – Mashhood
    Commented Sep 12, 2014 at 16:37
  • 1
    $\begingroup$ The implementation of the algorithm is literally nothing more than the XOR of the bytes of the message and pad. The real problem will be finding a true random number generator; java.util.Random isn't suitable for this purpose, nor is java.security.SecureRandom. $\endgroup$ Commented Sep 12, 2014 at 16:45

2 Answers 2

5
$\begingroup$

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

$\endgroup$
3
  • 2
    $\begingroup$ Careful Patriot. You're creating the impression that OTPs might actually be useable in practice. That can't be right. Can it :-) $\endgroup$
    – Paul Uszak
    Commented Jul 17, 2019 at 16:00
  • $\begingroup$ Seriously now - ref. TAPIR card. I thought that it was common to encode numerals in triplicate, not duplicate. Is that not common then? $\endgroup$
    – Paul Uszak
    Commented Jul 18, 2019 at 0:44
  • 1
    $\begingroup$ @Paul Uszak As you know, the TAPIR converts letters to numbers and provides structure to a message--this kind of fractionation was common amongst the East Germans (I do miss them) and Russians in the DDR/CCCP days. Then you pass a one-time pad of numerals over the fractionated plaintext. Not gonna break such traffic (without a compromise during key exchange/misuse/surreptitious entry/etc.). A mix of double and single letters was more common than triple-letter groups. $\endgroup$
    – Patriot
    Commented Jul 18, 2019 at 6:36
4
$\begingroup$

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
$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.