The Morse Code app can encrypt messages using Vigenère cipher. This page describes the concrete method used in the app including its pros and cons. You will also learn for what type of situations the cipher is suitable and when it should not be used.

Usage scenarios

This feature is useful mainly for games and for having a private conversation on a public channel where more people are listening. It is not suitable for transferring really sensitive information. Vigenère cipher is no match to modern cryptographic methods like AES. A determined attacker could write down your conversation and take some time to break it. If the message is sufficiently long, the chance of success is very high.

Why Vigenère cipher for Morse code

Now you probably ask why another much more secure encryption method has not been implemented in the app instead. The Vigenère cipher has many beneficial properties:

It is very tolerant to mistakes. If you receive one character incorrectly, you will have just one mistake in the deciphered message. The rest of it will be still readable. On the other hand, if a more secure method was used, a single incorrectly received character would make the whole message corrupted and you would have to send it again.
It does not change the length of the encrypted text. Modern encryption methods would make the message longer and therefore more difficult to send.
The spaces between words and the punctuation are preserved. This makes sending and receiving by humans much easier compared to the situation when the encrypted output would be just a very long line of nonsense letters and numbers without any structure.
The encrypted text contains only the same type of characters as the original message. Letters A to Z are encrypted again to one of the letters A to Z. You do not have to learn advanced Morse codes for less frequent characters if you want to send an encrypted message that contains only basic letters.

These properties make it much easier to send the encrypted message using Morse code. As mentioned, there are disadvantages that you should be aware of:

The method is much less secure compared to modern cryptographic methods and it should not be used for sending really sensitive information.
There is a logical consequence that might not be obvious at first. If an attacker is able to decrypt the message, then it would not be too difficult to derive also the password that has been used to encrypt it. This means that you should not use for the encryption the same password as you use elsewhere (for example, encrypting the message with the same password that you use to log into your e-mail account would not be a good idea).

How does it work

Before we describe Vigenère cipher, we have to start with its simpler version - Caesar cipher.

Caesar cipher

It is one of the simplest ciphers, which just shifts all letters in the message by some fixed number of positions down the alphabet. The key (password) is the number of shifts.

The key 1 means that each letter in the message will be simply replaced by the next letter (one position down) in the alphabet (A → B and so on). The following example shows how the word "message" is encrypted using the key 1.

Plaintext m e s s a g e
Ciphertext n f t t b h f

The next example shows again the word "message" but encrypted with the key 3.

Plaintext m e s s a g e
Ciphertext p h v v d j h

If you reach the end of the alphabet (letter Z), you just return to its start again (letter A). For example, the letter "X" shifted by 5 positions becomes X → Y → Z → A → B → C.

If you need more examples or more technical description, please refer to Wikipedia.

The decryption process is also very simple. The letters are shifted in the same way but in the opposite direction.

Instead of a number of shifts, the key can also be represented by a single letter - for example, A=0, B=1, C=2, and so on. As you can see, this cipher is too simple for any practical use. The password is only a single letter A to Z so there are only 26 possible passwords. It would be trivial to try them one by one.

Vigenère cipher

Vigenère cipher is an extension of the Caesar cipher where the password can have multiple characters. The first letter of the message is encrypted with the first letter of the password, the second letter of the message with the second letter of the password and so on. When you reach the last letter of the password, you just start again from its first letter.

The following example shows the word "message" encrypted with the password "abc". The result is "mfusbie".

Plaintext m e s s a g e
Password a b c a b c a
Shifts 0 1 2 0 1 2 0
Ciphertext m f u s b i e

The more technical description can be found on Wikipedia

This section discussed the how Vigenère cipher works in general. The particular implementation can differ. The main difference would be the choice of the used alphabet. For this example, "a" to "z" has been chosen. This effectively means that the plaintext message cannot contain other characters such as numbers or punctuation. Various Vigenère cipher modifications can solve this problem by using another larger alphabet.

Another important difference is the method that maps the password letters to the number of shifts. In this example we used a simple mapping a=0, b=1, c=2, and so on until z=25. The disadvantage is that the password could contain only lower-case Latin letters and any other characters (such as numbers) would not be supported. There can be other versions of the cipher with a different mapping allowing the password to contain also other characters.

As a result of that, if you encrypt a message with Vigenère cipher in one app, it is possible that it you would not be able to decrypt it in another app if they use slightly different versions of the cipher.

Version of Vigenère cipher used in the app

The Morse Code app uses the following parameters for the encryption:

  • Only letters and numbers are encrypted. Any other character is skipped. This means that spaces and punctuation will remain unchanged.
  • Two separate alphabets are used for encryption. One contains all letters in the currently selected Morse code version. In case of International Morse Code this alphabet is "abcdefghijklmnopqrstuvwxyz". Another separate alphabet is used for numbers (specifically "0123456789"). So a letter is mapped to another letter, and a number is mapped to another number.
  • The first alphabet for letters depends on the Morse code version selected in the app settings. If you have selected one of the local versions of the Morse code, the alphabet for letters will be derived from it (all single character letters will be taken from it in the same order in which they are displayed in the app). For example, in case of Greek Morse code, the alphabet for letters used for encryption will be "αβγδεζηθικλμνξοπρστυφχψω". This effectively means that only Greek letters (and numbers) would be encrypted in the message and any other characters (such as Latin letters) would be skipped.
  • If the message contains letters with accents and they are not present in the used alphabet, the accent is removed. For example, "é" is replaced with "e" before it is encrypted.
  • The characters from the password are mapped to the number of shifts by their Unicode number. You can find the Unicode number for a character for example in this List of Unicode characters. For any character of the password found in the column Glyph, the corresponding number of shifts can be found in the column Decimal. We have used a very simple mapping (A=0, B=1, C=2, ...) for demonstration purposes on this page. However, as you can see in the mentioned table, the real mapping used in the app is A=65, B=66, and so on. It is not a problem, that the number of shifts is greater than the number of the letters in the alphabet - when we reach the end of the alphabet, we simply return to its beginning with the next shift. Using the Unicode number has a big advantage that you can use any possible character in your password. The password is also case-sensitive in the app. If you look in the mentioned table, you can see that the lower-case "a" has a different code (97) than the upper-case "A" (65).

The plaintext "message" encrypted with the password "abc" in the app will become "fynlubx"

Plaintext m e s s a g e
Password a b c a b c a
Shifts 97 98 99 97 98 99 97
Ciphertext f y n l u b x

We will finish the description with a more complex example when the message "It's a secret message." is encrypted with the password "abc". This results in the cihpertext "Bn'l v mzvlzm hxmntaz.".

Plaintext I t ' s a s e c r e t m e s s a g e .
Password a b c a b c a b c a b c a b c a b c a b c a
Shifts 97 98 - 97 - 99 - 98 99 97 98 99 97 - 99 97 98 99 97 98 99 -
Ciphertext B n ' l v m z v l z m h x m n t a z .

The apostrophe, spaces and period in the plaintext message are not encrypted because they are not present in the used alphabet (it is not possible to determine the following letter for them).