Simple Cipher change proposal: rewrite the description

Follow up from this thread. The simple cipher description contains “steps” and an “extension”. It relates the cipher to Caesar quotes and a story line, as well as referring to the Caesar cipher, which confuses the actual instructions.

Note 1: simple cipher and rotational cipher are pretty similar. The primary difference is that rotational cipher uses a fixed distance while simple cipher uses a lowercase letter string to encode a sequence of distances.

Note 2: the simple cipher exercise is not, as far as I can tell, actually a “shift cipher” or “Caesar cipher”. Based on my reading of WIkipedia, a shift cipher has a fixed shift distance. The rotational cipher uses a fixed distance, making it a Caesar cipher. The simple cipher exercises uses the key to vary the distance. As such, it is not a Caesar cipher.

Note 3: I’m not sure what makes this cipher a “simple” cipher. It seems more involved than the rotational cipher and atbash cipher. However, renaming exercises is “expensive” so I opted to keep “simple” in the proposed description.

Proposal

Rewrite the existing description entirely.

  • No mentions of Caeser.
  • No mention of steps.
  • No mention of extension.
  • Rewrite the description to be in line with the format shared by multiple other cipher exercises.

Proposed instructions.md:

# Description

Create an implementation the [Vigenère cipher][wiki].
The Vigenère cipher is simple substitution cipher.

## Cipher terminology

A cipher is an algorithm used to encrypt, or encode, a string.
The unencrypted string is called the _plaintext_ and the encrypted string is called the _ciphertext_.
Converting plaintext to ciphertext is called _encoding_ while the reverse is called _decoding_.

In a _substitution cipher_, each letter is replaced with a different letter which is computed with the help of a _key_.

## Encoding details

In this cipher, the key is a series of lowercase letters, such as `"abcd"`.
Each letter of the plaintext is _shifted_ or _rotated_ by a distance based on a corresponding letter in the key.
An `"a"` in the key means a shift of 0 (that is, no shift).
A `"b"` in the key means a shift of 1.
A `"c"` in the key means a shift of 2, and so on.

The first letter of the plaintext uses the first letter of the key, the second letter of the plaintext uses the second letter of the key and so on.
If you run out of letters in the key before you run out of letters in the plaintext, start over from the start of the key again.

If the key only contains one letter, such as `"dddddd"`, then all letters of the plaintext are shifted by the same amount (three in this example), which would make this the same as a rotational cipher or shift cipher (sometimes called a Caesar cipher).
For example, the plaintext `"iamapandabear"` would become `"ldpdsdqgdehdu"`.

If the key only contains the letter `"a"` (one or more times), the shift distance is zero and the ciphertext is the same as the plaintext.

Usually the key is more complicated than that, though!
If the key is `"abcd"` then letters of the plaintext would be shifted by a distance of 0, 1, 2 then 3.
Using that key, `"hello"` would become `"hfnoo"`.

## Random keys

If no key is provided, generate a key which consists of at least 100 random lowercase letters from the Latin alphabet.

[wiki]: https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
4 Likes

The cipher used in this exercise is usually referred to as a Vigenère cipher. That name should appear somewhere.

3 Likes

Thanks for the name! I updated the first line or two of the description to use the name.

I’ll check back here tomorrow :slight_smile: Absent any further discussion, I’ll interpret those “likes” as a “go ahead” and work on a PR tomorrow (or whenever I find some time).

1 Like

I created a PR to implement the above proposal.

1 Like