Skip to content

Add Beaufort cipher codec#30

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-beaufort-encoding
Draft

Add Beaufort cipher codec#30
Copilot wants to merge 2 commits intomainfrom
copilot/add-beaufort-encoding

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

Checklist

  • No unrelated changes
  • Codec is new (not already implemented)
  • Tests included (if cannot be automated with tests/test_generated)
  • Documentation (included in the right page in docs/pages/enc)

Description

Adds the Beaufort cipher — a polyalphabetic substitution cipher using C = (K - P) mod 26 (key minus plaintext, vs. Vigenère's plaintext plus key). Self-reciprocal: encode and decode are the same operation.

  • src/codext/crypto/beaufort.py: New codec modelled after vigenere.py. Supports key via beaufort-<key> / beaufort_<key> naming. Since the cipher is self-reciprocal, beaufort_decode = beaufort_encode.
  • src/codext/crypto/__init__.py: Registered beaufort alongside the other crypto codecs.
import codext
codext.encode("ATTACKATDAWN", "beaufort-lemon")  # → "LLTOLBETLNPR"
codext.decode("LLTOLBETLNPR", "beaufort-lemon")  # → "ATTACKATDAWN"
Original prompt

This section details on the original issue you should resolve

<issue_title>Add new encoding: beaufort</issue_title>
<issue_description>### Description

The Beaufort cipher is a polyalphabetic encryption system very similar to the Vigenère cipher, but based on a different operation: instead of adding the key to the plaintext, the plaintext is subtracted from the key.

Reference

https://www.dcode.fr/beaufort-cipher</issue_description>

<agent_instructions>Please propose an implementation according to the guideline at docs/pages/howto.md.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Co-authored-by: dhondta <9108102+dhondta@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dhondta/python-codext/sessions/3b6ca95a-8125-40c8-8a1b-b70d5ea7e488
Copilot AI changed the title [WIP] Add new encoding for Beaufort cipher implementation Add Beaufort cipher codec Mar 23, 2026
Copilot AI requested a review from dhondta March 23, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add new encoding: beaufort

2 participants