Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add Playfair cipher in Ciphers - New Cipher #2809

Closed
JaydityaDhaka opened this issue Oct 10, 2024 · 3 comments
Closed

[FEATURE] Add Playfair cipher in Ciphers - New Cipher #2809

JaydityaDhaka opened this issue Oct 10, 2024 · 3 comments
Labels
enhancement New feature or request stale Author has not responded to the comments for over 2 weeks

Comments

@JaydityaDhaka
Copy link

JaydityaDhaka commented Oct 10, 2024

Detailed description

The Playfair cipher is a classical encryption technique that uses a 5x5 grid to encrypt pairs of letters (digraphs) in a message. This method helps obscure the frequency analysis of individual letters, making it more secure than simple substitution ciphers. The Playfair cipher works by substituting pairs of letters based on their positions in the grid, which is constructed using a keyword or phrase.

Context

I have previously implemented the Playfair cipher for a class project. While searching for existing code online, I found a lack of accessible implementations that would aid students in understanding and utilizing this cipher for their assignments. After spending two hours writing the code from scratch, I realized the importance of sharing this knowledge. By adding my implementation to an open-source platform, I hope to assist others who may find themselves in a similar situation. It would bring me great joy to see students benefit from my work while also aiming to earn the Hacktoberfest tag for this contribution.

Possible implementation

Here’s a possible outline of how to implement the Playfair cipher:

  1. Grid Construction:
  • Create a function to generate the 5x5 grid from a keyword.
  • Remove duplicate letters from the keyword and add the remaining letters of the alphabet (omitting 'J' or treating 'I' and 'J' as the same letter).
  1. Message Preparation:
  • Prepare the plaintext message by removing spaces and punctuation.

  • Split the message into pairs of letters (digraphs). If a pair contains the same letter, insert a filler letter (e.g., 'X') between them. If there's an odd letter at the end, pair it with a filler letter.

  1. Encryption Logic:
  • For each pair of letters, find their positions in the grid.

  • Apply the Playfair rules:

  • If both letters are in the same row, replace them with letters immediately to their right (wrap around if necessary).

  • If both letters are in the same column, replace them with letters immediately below (wrap around if necessary).

  • If the letters form a rectangle, replace them with letters on the same row but at the opposite corners of the rectangle.

  1. Decryption Logic:
  • Implement the reverse logic of the encryption process to retrieve the original message.
  1. User Interface:
  • Create a simple command-line interface that allows users to enter a keyword and plaintext message for encryption and decryption.

Additional information

  • Languages and Tools: This implementation can be done in C++, Python, or any programming language of choice that supports basic string manipulations and data structures.

  • Educational Value: The Playfair cipher serves as an excellent introductory exercise for understanding more complex encryption algorithms and cryptography concepts.

  • Potential Extensions: Consider adding features such as handling special characters, integrating user authentication, or creating a graphical user interface (GUI) for better usability.

@JaydityaDhaka JaydityaDhaka added the enhancement New feature or request label Oct 10, 2024
@JaydityaDhaka
Copy link
Author

Pull Request

Copy link
Contributor

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Author has not responded to the comments for over 2 weeks label Nov 18, 2024
Copy link
Contributor

github-actions bot commented Dec 9, 2024

Please ping one of the maintainers once you add more information and updates here. If this is not the case and you need some help, feel free to ask for help in our Gitter channel or our Discord server. Thank you for your contributions!

@github-actions github-actions bot closed this as completed Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale Author has not responded to the comments for over 2 weeks
Projects
None yet
Development

No branches or pull requests

1 participant