wierkstudio / ciphereditor

Web app for cryptography, coding and data encouraging beginners and pros alike to explore new operations and build own workflows.
https://ciphereditor.com
MIT License
115 stars 22 forks source link

Add vigenere cipher operation #5

Closed anderium closed 2 years ago

anderium commented 2 years ago

This PR adds the Vigenère cipher operation to the @ciphereditor/extension-essentials. The code is based on the Caesar cipher and cryptii code for the Vigenère cipher.

Four different variants of the cipher are available, just like Cryptii.

  1. Traditional Vigenère cipher: inputIndex + alphabetIndex,
  2. Beaufort cipher: alphabetIndex - inputIndex,
  3. Variant Beaufort cipher: inputIndex - alphabetIndex,
  4. Trithemius cipher: Vigenere with fixed key and key mode.

The code gives an error when the key is empty or contains characters not in the alphabet. If none of the plain-/ciphertext characters are from the alphabet, it warns the user to avoid confusion.

The Trithemius cipher uses a fixed key and key mode. Currently, this is not communicated to the user, this can be part of an upcoming update.

The images below show the difference between key mode “repeat” → `keykey` and “auto-key” → `keymessage`, the cipher variants and the errors & warning. (The first and third image were created before the variants were implemented, hence they lack that control.) vigenere cipher example vigenere cipher variants vigenere cipher errors

I did my best attempt at writing a description for the operation, but I'm unsure if it is easily understandable in its current form.

PS: It was fun to do this, the system feels nice and is self-documenting for the most part. The most obvious place where something could be simplified with less code duplication is already addressed in the backlog as well: https://github.com/wierkstudio/ciphereditor/blob/c722c049cf8ebfcf9b4ffdbe71577135508f459a/packages/app-web/src/slices/directory/index.ts#L6-L7

vercel[bot] commented 2 years ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
ciphereditor ✅ Ready (Inspect) Visit Preview Jul 30, 2022 at 10:43PM (UTC)